heres my script i made using different scripts around it works but i want to improve some things, it basically create a playlist to every folder containing an album, now i have to select all folders and drop them on the droplet
on open (the_items)
set folder_count to 0
tell application "Finder"
set the_count to (count the_items)
repeat with f from 1 to the_count
set this_item to item f of the_items
set theName to this_item as string
set old_delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set playlist_name to text item -2 of theName
set AppleScript's text item delimiters to old_delims
set folder_count to folder_count + 1
tell application "iTunes"
set new_playlist to make new user playlist
set name of new_playlist to playlist_name as string
add this_item to new_playlist
end tell
end repeat
end tell
end open
what i want to improve for example:
-be able to use it from the script menu in itunes
-so it can scan one folder where i keep all my albums (all folders are at the same level)
i have a problem using “list folder” command, the system says it cant get the name of the folders
please help ill post on applescript itunes website
I’m not entirely sure why you’d want to add this to iTunes’ script menu since I wouldn’t expect it to be something you’re likely to want to run frequently, but if you want to, all you need to do is save your script in ~/Library/iTunes/Scripts/ and it’ll appear.
With respect to adding multiple playlists, one for each folder, something like this should work (untested):
set topFolder to choose folder with prompt "Choose the top level folder"
tell application "Finder"
set albumList to every folder of topFolder
repeat with anAlbum in albumList
set tracks to every file of anAlbum
tell application "iTunes"
set new_playlist to make new user playlist with properties {name:name of anAlbum as string}
add tracks to new_playlist
end tell
end repeat
end tell
This will create a new playlist for each folder inside the folder you select at the beginning, and it will add each file inside that folder to the new playlist.
thank you for answer
it does create a new playlist with correct name corresponding to each folder
BUT playlist are empty
i found an app (which is a droplet script ) that does the job but i still think its more elegant to get the job done from the script menu
(strangely
add album_tracks to new_playlist
is different from
add tracks to new_playlist
in script editor in the later case “tracks” is in blue
but there is no difference in the result
You did change both references to ‘tracks’, right?
set topFolder to choose folder with prompt "Choose the top level folder"
tell application "Finder"
set albumList to every folder of topFolder
repeat with anAlbum in albumList
set the_Tracks to every file of anAlbum
tell application "iTunes"
set new_playlist to make new user playlist with properties {name:name of anAlbum as string}
add the_Tracks to new_playlist
end tell
end repeat
end tell