I found samples but I guess my real question is about Applescript itself. Is everything a special case?
To add a track to a play list, this seems to work although it is slow:
tell application "iTunes"
repeat with t in tracks of playlist "Podcasts"
if (unplayed of t is false) and (played count of t is 0) then
set l to location of t
add l to playlist "Temp Podcast List"
end if
end repeat
end tell
It appears to be making copies somehow.
Why do I need to take the location? A playlist has “tracks”, not locations. So why doesn’t:
add t to tracks of playlist "Temp Podcast List"
work?
Or, for that matter, why doesn’t:
add location of t to playlist "Temp Podcast List"
work?
Notice that “location” is not even an (documented) attribute of “track” (or “item”) (according to the script editor). But more to the point, my real question is how do I figure this out from the documentation? How do I write code rather than typing like a monkey until something pretends to work?
Next comes the question of removing a track from a playlist. I’ve yet to see how this is done. I did find really complicated scripts just to remove a single item from a list. It all seems so out dated.
I want to do this:
tell application "iTunes"
repeat with t in tracks of playlist "Temp Podcast List"
if played count of t is not 0 then
delete t from playlist "Temp Podcast List"
end if
end repeat
end tell
Or something similar. Taking the location of t doesn’t work in this case.
I’m tempted to try the Ruby interface to Applescript. Ruby is much more consistent. But I assume that I’m going to get trapped by the same underlying non-orthogonality of Applescript.
I keep trying to understand Applescript but I must be going about it entirely wrong.