Calling one script from another on application close

This is my first go at writing an applescript. Basically I want to open itunes and when it quits, run another applescript.

Here’s what i’ve got so far:

tell application "Finder"
	run application "iTunes"
end tell

on idle
	tell application "System Events" to set iTunesHasQuit to not (application process "iTunes" exists)
	if iTunesHasQuit then
		run script alias "Macintosh HD:Users:paul:Desktop:reset_itunes_folders"
	end if
	return 5
end idle

The problem is that when I try to compile I get an error telling me the file for my other applescript wasn’t found. It is stored on my desktop (~/Desktop/reset_itunes_folders.scpt) , so as far as I can tell it should work.

Anyone got any ideas? I must be doing something very simple wrong here.

Cheers,
Paul.

Welcome. :slight_smile:

You didn’t include the extension in the script.

While you’re at it, you can remove the tell Finder block and make the path more portable.

activate application "iTunes"

on idle
	tell application "System Events" to set iTunesHasQuit to not (application process "iTunes" exists)
	if iTunesHasQuit then
		run script alias ((path to desktop as Unicode text) & "reset_itunes_folders.scpt")
	end if
	return 5
end idle

Excellent that did exactly what I wanted, thanks a lot Bruce.