timeout in iTunes (newbie level)

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.

What obvious thing am I missing?

I think you should place ‘with timeout … end tell’ outside of 'tell app “iTunes” … end:

with timeout of 3000 seconds
	tell application "iTunes"
		convert aTrack
	end tell
end timeout
--do otherStuff

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)

hmmm - I tried it and this script works for me:

tell application "iTunes"
	set a to file track id 28590 of user playlist id 28587 of source id 40 -- (just an example of course...)
	convert a
end tell