Trying to convert an audio track to a different encoding and then do something with the result (e.g. audio CD to AAC, then change album name). Why doesn’t this work properly with timeout?
tell application "iTunes"
with timeout of 3000 seconds
convert aTrack
end timeout
--do otherStuff
end tell
When run, the script instantly throws an “Apple Event timed out” error and then starts to convert the track, but the script is no longer running. It’s not even to do with the CD drive being slow, because converting a three-minute audio track on the hard drive does exactly the same thing even though the convert is very fast.
No, that’s not it. The whole thing’s an iTunes script, so it makes sense for all the rest of the setup (including choosing cd drive/track to convert etc) to be inside the main application tell block.
What does seem to work is the following, copied from a Doug Adams script:
set newT to (convert track trackRef)
Now I think about it, I didn’t think I needed a return variable because I wasn’t particularly going to do anything with it, just go on to the next bit of the script, but presumably the return value tells it that that action is now completed, and it can go on to the next thing, as opposed to firing it off and then getting confused because it tries to do the next bit instantly. I think. So I was looking at the timeout, but that wasn’t where the problem was. (memo to self, think about return values more)