One really nice thing about Mac OS X is the ease with which you can automate tasks. This comes down to AppleScript – an easy-to-learn scripting language for getting apps to do things – and Automator, a drag-and-drop tool for creating a series of automated actions, known as a workflow.
In this beginner Automator tutorial I’ll walk you through the process of creating a simple Automator workflow, from start to finish. The workflow, called “Zip and Send”, will zip up selected file(s) and automatically email the resulting zip archive to an address you specify.
To run Automator, open your Applications folder in the Finder and double-click the Automator icon. When Automator starts, you can choose a starting point for a new workflow:
These options just provide basic templates to get you going. For now, just choose the Custom icon, as shown above, then click Choose.
About Automator Actions and Workflows
The Automator window contains an Actions/Variables area (on the left) and a Workflow pane (on the right):
There’s also a small bottom-left pane that describes each action or variable.
What are actions, workflows and variables? I’ll cover variables in another tutorial; here we’ll concentrate on actions and workflows.
Actions are simple tasks that Automator asks other apps to carry out, such as “New Folder” or “Pause iTunes”. You string actions together to make a workflow, which is a script of tasks for Automator to run. You can then save your workflow and run it whenever you like.
Many actions have an output (such as a piece of text or a file name) that is then passed to the next action as an input. This is indicated by a little arrow symbol between the 2 actions:
Building the Workflow
Here you’ll create a simple but useful workflow to zip up some selected file(s) and email the zip file to a specified email address. Follow these steps to create the workflow:
1. Add an action to create a temporary folder for the zip archive
In the Actions/Variables pane click Files & Folders in the left-hand column, then drag the New Folder action in the right-hand column into the right-hand Workflow pane. Click the Name field in the action and type ArchiveTemp. Make sure Where is set to Desktop – this will create the ArchiveTemp folder on your Desktop:
2. Add an action to get the items selected in the Finder
With Files & Folders still selected in the left-hand column, drag the Get Selected Finder Items action below your previously-created New Folder action in the workflow. This action grabs the names of any selected files and folders in the Finder and passes them as input to the next action:
3. Add an action to remove the temporary folder from the selected items
Unfortunately the selected items grabbed by the second action will also include the ArchiveTemp folder created by the first action, so you need to remove this folder from the list of selected items. You can do this with the Filter Finder Items action. As before, drag this action below the other actions in your workflow. Set the first option to Name and the second option to is not equal to, then type ArchiveTemp into the box:
4. Add an action to create the archive
Now you’re ready to add an action to create a Zip archive of the selected items. First though, you need to manually create the ArchiveTemp folder on your Desktop so you can tell the action where to save the archive. So right-click (or Control-click) your Desktop, choose New Folder, and name the folder ArchiveTemp.
Now switch back to Automator and drag the Create Archive action into the workflow, below the other actions. Click the Where option in the action, choose Other from the pop-up menu and select the ArchiveTemp folder that you just created on your Desktop. Leave the Save as box saying Same name as input – this will name the archive after the selected file (if more than one file was selected, it will call the archive simply “Archive.zip”):
5. Add actions to send the email message
The next step in the workflow is to send the created archive file as an email attachment. Click Mail in the left hand column, then drag the New Mail Message action to the bottom of your workflow. Click the Options button at the bottom of the action to display the action options, then click the Show this action when the workflow runs checkbox. This will pop up a dialog prompting for the recipient and other details when the workflow is running:
The New Mail Message action takes the archive file generated by the previous Create Archive action, and attaches the file to a new email message.
To actually send the message, you need to use the Send Outgoing Messages action. Drag this action below the New Mail Message action in the workflow:
6. Add actions to remove the temporary folder
That’s the archive created and emailed. All that’s left to do now is clean up by moving the ArchiveTemp folder to the Trash.
First, add an action to select the ArchiveTemp folder. Click Files & Folders in the left column, then drag the Get Specified Finder Items action to the bottom of your workflow. Click the Add button in the action, then in the dialog that appears choose the ArchiveTemp folder on your Desktop:
Finally, drag in the Move Finder Items to Trash action to delete the ArchiveTemp folder:
Testing the Workflow
You’ve now created your workflow! To test it, first switch to the Finder and click a (reasonably small) file or folder to select it. Then switch back to Automator and click the top-right Run button. You’ll see Automator moving through each action in your workflow. When it’s time to send the email, you’ll get a dialog asking you to enter the email details – do this, then click Continue:
Automator now automatically composes and sends the email. Job done!
Saving the Workflow
The last step is to save your workflow so you can use it again later. There are a few different ways you can save workflows. In this example you’ll save your workflow as a Finder plug-in so you can run it straight from the Finder.
Choose File ⇨ Save As Plug-in, then make sure Finder is selected and enter Zip and Send. Click Save to save your workflow:
You can now easily zip and send any selected file(s) or folder(s) in the Finder. Select the item(s), then right-click (or Control-click) one of the items and choose More ⇨ Automator ⇨ Zip and Send:
I hope you found this Automator tutorial helpful. Let me know if you like it and I’ll write some more tutorials!