Works in Script Editor, Times out in iTunes script menu...

I am working on an Applescript that converts aac files to mp3 to help prepare mp3 discs. (I got a sweet mp3 car stereo for Christmas!) My script works perfectly when run from the Script Editor, but when I plop the script into the iTunes Scripts folder and try to run it from iTunes, I get an “Apple Event Time Out.” Anyone know why?

Rather than litter the forum posting with my whole script, I thought I would create a sample script that demonstrates the problem:

tell application "iTunes"
	set sPlaylist to (get view of front window)
	repeat with i from 1 to (count tracks of sPlaylist)
		set fKind to kind of (track i of sPlaylist)
		if fKind is "AAC audio file" then
			-- convert aac to mp3 using iTunes
			set newT to item 1 of (convert (track i of sPlaylist))
		end if
	end repeat
end tell

: In iTunes, select a playlist full of (unprotected) AAC files
: First, take above code and run it from Script Editor (should work great)
: Next, make a scpt file and put it in the iTunes Script folder to run it from within iTunes (will error)

Anyone have any advice on how to fix this? Thanks!

I thought I’d ping this post since it has been a few days with no reply… :slight_smile:

(I’ve also posted this question on the Apple discussion board.)

http://discussions.info.apple.com/webx?14@589.czXta1rpHat.6@.68a2c179

Try saving the script as “Application”, rather than plain ol’ “Script”.

I had a similar problem with the Autobooker script for iTunes. I just put the script in the apple script menu. It worked there without timeing out.

Excellent!

Making the Applescript an “application” solved the problem. The script now works as expected from the iTunes script menu! Woohoo!

Thanks Doug!