tell application "iTunes"
set testFolderPlayList to make folder playlist with properties {name:"test"}
make folder playlist at testFolderPlayList with properties {name:"test2"}
end tell
Although the folder playlists seem nested, they are all on the same playlist level
tell application "iTunes"
set test2FolderPlayList to folder playlist "test2"
make folder playlist at test2FolderPlayList with properties {name:"test3"}
end tell
Thanks for the quick reply. If all folder playlists are at the same playlist level, then this complicates what I am trying to achieve.
For example, if I had the following, which iTunes allows you to do, then how do I know which “70s Albums” playlist folder I would be referring to in order to insert another subfolder.
Aerosmith
----------------------> 70s Albums
Whitesnake
---------------------> 70s Albums
Confusingly, iTumes even seems to allow identically named playlist folders at the same level. So, is there another method of referring to them? “PresistentID” seems to ring a bell, but I can’t remember where I saw that - possibly in another Applescript I was looking at on Doug’s scripts for iTumes website.
folder playlists have a parent property which contains the parent element.
Unfortunately it cannot be determined with the whose filter, so use a repeat loop
set aeroSmithPlaylist to missing value
tell application "iTunes"
set Albums70sFolders to folder playlists whose name is "70s Albums"
repeat with oneFolder in Albums70sFolders
if parent of oneFolder is folder playlist "AeroSmith" then
set aeroSmithPlaylist to contents of oneFolder
exit repeat
end if
end repeat
if aeroSmithPlaylist is not missing value then
make folder playlist at aeroSmithPlaylist with properties {name:"1975"}
end if
end tell
Thanks once again. Thinking about this, I might have been over complicating things.
I have a script that makes a playlist for each album in my library, creates a playlist folder named after the album, and then moves the playlist to the playlist folder . These are all stored in a “Albums” playlist folder
I also have another script that makes a playlist folder for each artist in the library, which are stored in a “Artists” playlist folder.
What I would like to do is move each album playlist folder to reside in the Artists folder, underneath the relevant Artist playlist folder. Is there a simple way to achieve this? Something like:
“Set targetartist to artist of track 1 of playlist PlRef”
“Move parent folder of playlist PlRef to playlist folder targetartist”
I.E.
Albums
--------------------> Pump (with playlist of Pump contained within)
Artists
--------------------> Aerosmith
--------------------------------------> Move the “Pump” playlist folder and the playlist it contains to here
Thanks for the help so far. I don’t have much AppleScript experience and your examples help immensely.
Got this working now. It is the Persistent ID that is the key to use, i.e.
tell application "iTunes"
set targetartist to (the artist of track 1 of playlist "Get A Grip")
set sourceplfolder to persistent ID of (some folder playlist whose name is "Get A Grip")
set destplfolder to persistent ID of (some folder playlist whose name is targetartist)
move (some folder playlist whose persistent ID is sourceplfolder) to (some folder playlist whose persistent ID is destplfolder)
end tell
I’m trying to move some already created (but empty) playlist folders named the same as an existing playlist (i.e. playlist of “2X again” and a empty playlist folder of "2X again) to sit under a playlist folder named after the artist of track 1 of the playlist, and then the move the playlist itself to the empty playlist folder)
I.E.
Playlist of “Appetite for Destruction” (artist of track 1 is “Guns n’ Roses”)
Move empty playlist folder of “Appetite for Destruction” to playlist folder named “Guns n’ Roses”.
Move “Appetite for Destruction” playlist to playlist folder named “Appetite for Destruction”
This is the code I am trying:
tell application "iTunes"
set excludedplaylists to {"Library", "Music", "Movies", "TV Shows", "Podcasts", "Books", "Purchased", "iTunes DJ", "Top 25 Most Played", "80's Cheese"}
set PlayListComplete to name of every playlist
repeat with thePlaylist in PlayListComplete
set prohibited to false
if thePlaylist is in excludedplaylists then
set prohibited to true
end if
if not prohibited then
set sourcealbumpl to persistent ID of (some playlist whose name is thePlaylist)
set targetalbumfolder to the album of track 1 of (some playlist whose persistent ID is sourcealbumpl)
set targetartist to the artist of track 1 of (some playlist whose persistent ID is sourcealbumpl)
set destalbumplfolder to persistent ID of (some folder playlist whose name is targetalbumfolder)
set destartistplfolder to persistent ID of (some folder playlist whose name is targetartist)
move (some folder playlist whose persistent ID is destalbumplfolder) to (some folder playlist whose persistent ID is destartistplfolder)
move (some playlist whose persistent ID is sourcealbumpl) to (some folder playlist whose persistent ID is destalbumplfolder)
end if
end repeat
end tell
But I get the following:
error “iTunes got an error: Can’t get album of track 1 of some playlist whose persistent ID = "17D0AB8AE89C947E".” number -1728 from album of track 1 of some playlist whose persistent ID = “17D0AB8AE89C947E”
This is driving me nuts because it’s so inconsistent. Sometimes the code I posted previously works for a few playlists then gives the error again, i.e.