Make Scripts Wait Till An Action Ends

This script executes a shell script (to queue an html doc into an app called Calibre), then has Finder delete the html doc:


do shell script “calibre /Users/pault/Documents/text.html”
delay 15
tell application “Finder”
delete file “Hard Drive:Users:pault:Documents:text.html”
end tell


The script takes 5 to 15 seconds to execute, so the “delay 15” is my quick/dirty solution. It works. But I want to make it more elegant by having the script check for the process having ended, and then do the deletion. Any tips?

Note: I don’t want to simply have the script keep repeating the deletion action until it works. That’s hardly more elegant! :slight_smile: