Quit Script

My Script keeps reapeating until all the files are done in the filelist. I need a way to Quit if I don’t want to do all the files in the list. Like if I hold down my Escape key it quits the script.

repeat with thisFileName in filelist
If key Escape then
return “Quit”
end if
end repeat

No need to do that, as a script is running and it is in a loop, hitting escape or Command-. should work to cancel out of the loop (you may get an error: User has canceled something or other). This should work if the script is run from the Script Editor or on it’s own as an application. The only caveat is that the script app or SE (whichever you are using to run the script) must be the frontmost app to receive the cancel request (it sometimes helps to hit Command-. a few times). If this doesn’t work for you, you’ll need something like Jon’s Commands which allows you to capture which keys are pressed and in your repeat loop, just add a check to see if a specific key is pressed and, if so, exit the loop.

HTH,
Jon