Make Automator Work for You

More Stories in this Series

Troubleshoot your workflows

Automator is usually straightforward—drag the actions you want into whatever order you want, and then click on Run. When something goes wrong, though, you’ll be glad to have the following tips on hand.

Hunt down mistakes

If your workflow isn’t working, there’s a good chance that an action is at fault. Track down such an error with the Automator: View Results action. Just stick View Results after any other action, and when you run your workflow, View Results will show you the output of the previous action.

Say you’ve designed a workflow that uses the iTunes: Find iTunes Items action to find songs in iTunes. To test your workflow, insert the View Results action after the Find iTunes Items action. If you get back the result

{}
(an empty list) when you run the workflow, you’ll know that the search isn’t finding any songs that match your criteria—and that it’s time to broaden your search.

Beware of mismatched actions

Typically, an Automator action sends its results to the following action in the workflow. Automator represents this relationship with a little arrow that points from one action into the next.

However, sometimes there isn’t an arrow between actions; instead, the result of one action and the input of the next one both appear in red text. Consider this a warning: the type of information the first action produces may not be the type of information that the second action expects. Depending on your workflow, this input/result mismatch may cause problems—you should consider rearranging your workflow.

When in doubt, disable

If an action seems to be holding up your workflow, don’t delete the action—disable it instead. To do so, click on the number in its upper left corner and select Disable in the menu that appears. Automator will skip over that action while you troubleshoot your workflow. When you’re ready to enable the action again, choose Enable from the same menu.

Pause a workflow

If one of your workflows takes its sweet time, you might want Automator to notify you when some part of it has completed. The trick is to insert the Automator: Ask For Confirmation action after the relevant part of the workflow, forcing Automator to pause the entire workflow at that point. (You can also use the Ask For Confirmation action to pause your workflow so you can make changes to whatever it’s working on.) Just remember to enter something descriptive in the Message and Explanation fields: for example, “Hey there, the workflow just finished converting your images.”

Track your workflow’s progress

You can tell which actions in your workflow have run by the little symbols next to each one in the Workflow pane. A green check mark means the action has completed, a spinning progress indicator means the action is running, and if neither is visible, the action hasn’t run yet. But do yourself a favor—go to Automator and choose the View: Show Log menu item instead. A drawer will open at the bottom of the Automator window. In it, you’ll see not only which actions have run but also how long each action took—a great way to discover bottlenecks.

Dodge finder action mix-ups

One of the easiest mistakes to make in Automator is using Finder: Get Specified Finder Items when you mean to use Finder: Get Selected Finder Items. Get Specified Finder Items lets you enter a list of files and folders for the workflow to use before you even run the workflow. (The only way to change the items is to go back and change the Get Specified Finder Items action in the Workflow pane.) The Get Selected Finder Items action operates on the files and folders selected in the Finder when you run the workflow. That’s much more convenient, since you don’t have to modify the action itself when you want it to work with different files.

Take precautions changing images

Whenever you insert a Preview action that modifies images on your hard drive, Automator asks whether you’d like to insert another action—one that will make copies of the images—first. If you want to avoid image accidents, take Automator’s advice. In the dialog box that appears, click on Add, and your workflow will use duplicate images instead.

[ Adam Goldstein is the author of AppleScript: The Missing Manual (O’Reilly, 2005). ]

Subscribe to the Best of Macworld Newsletter

Comments