Hello All,
I am trying to use some AppleScripts to do stuff in iTunes, but I am running into many problems. A lot of AppleScripts work so long as all the MP3 files are not locked, but if they are locked then the AppleScript throws an error. This is particularly frustrating because the AppleScripts are simply automating things that iTunes can do and does do to all MP3s regardless of whether they are locked or not.
Example code: (from http://dougscripts.com/)
When this script is invoked, it should skip to the next track and increment the play count of the song that it just skipped away from. This works if the current song is unlocked. This DOES NOT work if the current song is locked. It does skip to the next track, but it fails to change the play count. Now, if you actually let the song finish playing in iTunes, then iTunes has no problem incrementing the play count.
Why can iTunes do this "naturally", but the AppleScript cannot?
Another AppleScript reports "file permission error" (just like that, not capitalized or anything) when I try to set the play count to an arbitrary number. Again, this seems strange because iTunes itself can set the play count to zero without complaining.
A related question might be, where does iTunes store all this metadata? Does it like to store it on the files themselves, but it forced to store it in the ITDB file if the files are locked, but AppleScript doesn't know how to handle this contingency? That seems like a likely explanation to me. How can we make the AppleScripts comfortable with this, just like iTunes is by default?
Thanks.
I am trying to use some AppleScripts to do stuff in iTunes, but I am running into many problems. A lot of AppleScripts work so long as all the MP3 files are not locked, but if they are locked then the AppleScript throws an error. This is particularly frustrating because the AppleScripts are simply automating things that iTunes can do and does do to all MP3s regardless of whether they are locked or not.
Example code: (from http://dougscripts.com/)
Code:
tell application "iTunes"
if player state is not stopped then
try
tell current track
set played count to (get played count) + 1
set played date to (get current date)
end tell
end try
next track
end if
end tell
When this script is invoked, it should skip to the next track and increment the play count of the song that it just skipped away from. This works if the current song is unlocked. This DOES NOT work if the current song is locked. It does skip to the next track, but it fails to change the play count. Now, if you actually let the song finish playing in iTunes, then iTunes has no problem incrementing the play count.
Why can iTunes do this "naturally", but the AppleScript cannot?
Another AppleScript reports "file permission error" (just like that, not capitalized or anything) when I try to set the play count to an arbitrary number. Again, this seems strange because iTunes itself can set the play count to zero without complaining.
A related question might be, where does iTunes store all this metadata? Does it like to store it on the files themselves, but it forced to store it in the ITDB file if the files are locked, but AppleScript doesn't know how to handle this contingency? That seems like a likely explanation to me. How can we make the AppleScripts comfortable with this, just like iTunes is by default?
Thanks.