Kleines Skript, welches einen einstellbaren Ordner in iTunes importiert und im Anschluss die iTunes Mediatheak auch von nicht mehr vorhandenen Tracks bereinigt.
try
set defaultFolder to my decode_octal(do shell script "defaults read com.hubionmac.syncfolder2itunes defaultFolder")
display alert "Change default folder?" & return & return & defaultFolder buttons {"Change", "no changes"} default button {"no changes"} giving up after 2
if (button returned of the result) as text = "Change" then
error
end if
on error
set defaultFolder to POSIX path of (choose folder)
do shell script "defaults write com.hubionmac.syncfolder2itunes defaultFolder " & quoted form of defaultFolder
end try
set thefolder to (POSIX file defaultFolder) as alias
with timeout of 99999 seconds
tell application "iTunes"
--add thefolder to library
add thefolder to playlist 1 of source 1
end tell
end timeout
my remove_missing()
display notification "Done"
on remove_missing()
tell application "iTunes"
set the stored_setting to fixed indexing
set fixed indexing to true
set sourcename to name of source 1
tell source sourcename
set libname to name of playlist 1
tell playlist libname
repeat with i from the (count of tracks) to 1 by -1
try
if the location of track i is missing value then
delete track i
set the remove_counter to the remove_counter + 1
end if
end try
end repeat
end tell
end tell
set fixed indexing to the stored_setting
end tell
end remove_missing
on decode_octal(str)
set str to quoted form of str
set cmd to quoted form of "#!/usr/bin/python
import sys
x = sys.argv[1]
x = x.decode('unicode_escape' )
x=x.encode('utf-8')
print x"
set cmd_full to "python -c " & cmd & " " & str
set r to do shell script cmd_full
return r
end decode_octal
[…] An interesting script to sync a folder to itunes. (HT: Rocket Ink) I don’t think I’d want to use it due to the problems of deleting entries from iTune if the track isn’t in the file system right then. (Yes, I speak from experience – but it’s an even bigger problem I suspect with iTunes Match) […]
Hi,
ich mag das Skript und besonders toll finde ich, dass der Ordner rekursiv nach importierbaren Dateien durchsucht wird. Aber ich verstehe nicht den Part mit der Playlist – was sagt die Zeile
add thefolder to playlist 1 of source 1
konkret aus? Was ist playlist 1? Und wofür steht source 1?Am Schönsten wäre es, wenn es einen zusätzlichen Dialog gäbe, in dem mir die vorhandenen Wiedergabelisten angezeigt werden und ich die Möglichkeit habe eine neue anzulegen – geht das?!
Hallo Michael,
playlist 1 of source 1 is die Library (Mediathek).
So einen Dialog könnte ich einbauen, nur eigentlich ist das Skript dazu gedacht iTunes ohne Nutzer-Abfrage mit einem Ordner abzugleichen. Wenn Du Dir aber die iTunes Scripts von der Seite (Softwareschmiede) lädst, gibt es da ein anderes Skript, welches komplette Ordner-Strukturen an Hand von Playlisten in iTunes nachbauen kann, vielleicht passt das besser zu dem, was Du damit vor hast.
Gruß Hubi