I'm making an app in Automator to quickly delete my iMovie Library (to save space). However, I want my app to check if the iMovie Library has already been deleted and show a dialog saying so. I know how to make the dialog, but I can't figure out how to do it. How do I do this? I'm using macOS 10.11.

My workflow:

  1. Ask for confirmation
  2. Get specified Finder items (the validation would go after this)
  3. Move Finder items to trash
  4. Run AppleScript (to show a dialog saying "Done")
  • Show us the workflow and code you already have. Also what version of OS X/macOS are you running? May 20 '17 at 18:46

You can use a Run AppleScript action to perform validation. Between actions 2 and 3 in your workflow, add a Run AppleScript action with the following:

on run {input, parameters}
    if input is {} then
        display notification "File already deleted"
        tell me to quit
    end if
    return input
end run

This checks if the input is empty (because the file can't be found), and if so, runs your desired code — you can customise display notification as you please, such as showing an alert. The use of tell me to quit if the input is empty will stop the workflow at this point.

You must log in to answer this question.