I'm trying to script the creation of folders and subfolders in iTunes so that I get:
Albums
-- Pop
-- Rock
-- etc...
But, I'm hung-up on what should be a simple if not exists statement which, for some reason, is always coming back as "false" and creating a subfolder with the same name.
The code below is just a sample bit I'm using to try to get this working. Eventually (if I can ever get this working) is to loop through all the album titles in my library create a folder for each genre under the main Album folder, then create a playlist for the album in the appropriate genre.
The first if not block works correctly when I run the script multiple times, but the second block which creates the subfolder always creates a new instance with the same name (ie, if I run the script 3 times, I get 3 folders named Rock under Albums).
I've also tried
Any ideas as to what I'm doing wrong?
Albums
-- Pop
-- Rock
-- etc...
But, I'm hung-up on what should be a simple if not exists statement which, for some reason, is always coming back as "false" and creating a subfolder with the same name.
The code below is just a sample bit I'm using to try to get this working. Eventually (if I can ever get this working) is to loop through all the album titles in my library create a folder for each genre under the main Album folder, then create a playlist for the album in the appropriate genre.
Code:
tell application "iTunes"
if not (exists folder playlist "Albums") then
make folder playlist with properties {name:"Albums"}
end if
if not (exists folder playlist "Rock" of folder playlist "Albums") then
make new folder playlist at folder playlist "Albums" with properties {name:"Rock"}
end if
end tell
The first if not block works correctly when I run the script multiple times, but the second block which creates the subfolder always creates a new instance with the same name (ie, if I run the script 3 times, I get 3 folders named Rock under Albums).
I've also tried
Code:
if (exists folder playlist "Rock" of folder playlist "Albums") is false then
make new folder playlist at folder playlist "Albums" with properties {name:"Rock"}
Any ideas as to what I'm doing wrong?