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.

Opening Automator

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:

(Click image to enlarge)

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):

(Click image to enlarge)

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:

(Click image to enlarge)

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:

(Click image to enlarge)

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:

(Click image to enlarge)

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”):

(Click image to enlarge)

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:

(Click image to enlarge)

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:

(Click image to enlarge)

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:

(Click image to enlarge)

Finally, drag in the Move Finder Items to Trash action to delete the ArchiveTemp folder:

(Click image to enlarge)

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:

(Click image to enlarge)

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:

(Click image to enlarge)

All done!

I hope you found this Automator tutorial helpful. Let me know if you like it and I’ll write some more tutorials!

Bookmark this post:

This entry was posted
on Monday, July 27th, 2009 at 12:34 pm and is filed under Mac tips & tricks.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.

39 Responses to “Automator Tutorial: Getting Started with the Mac OS X Automator”

I am trying, unsuccessfully, to have a Keynote slide show automatically run when the computer comes on. I am in a retirement home and have created a nice slide show the weekly activities that runs on a G4 Mac connected to Comcast in-house TV channel. This play on the residents’ TV channel 33.
I want the Mac to shut down at night and on in the morning and the slide show to do likewise. Keynote and iTunes both open on startup but I can’t get the slide show to run automatically on startup.
In Automator I select “Open Keynote Presentations. Next I dragged the presentation file and dropped it into Automator. Test run did nothing. What am I doing wrong? David

@David: To have the Automator workflow run at login, save the workflow as an application (File > Save As, then choose Application for the File Format option), then add the application to Login Items (Apple menu > System Preferences > Accounts > Login Items).

Not sure why your workflow doesn’t work – it works OK for me. When you drag in your .key file Automator should create a “Get Specified Finder Items” action for it. Make sure this action is *before* the “Open Keynote Presentations” action in the list (you might need to drag the actions around).

I want to know if it is possible to generate a workflow code to do the following.

1 – Open a text file
2 – Text file has 1 or 2 words with a paragraph (the word describes what is in the para)
3) Find specific words within the para, count them, write the count to a spreadsheet
4) Move to the next para, repeat.

If this can be made as a plug in to work with text edit is what I am intending to do.

@Raj: Again, this sounds like something you’d want to use AppleScript and/or shell scripting for – not sure this level of detail is possible with Automator alone. I may write some AppleScript tutorials soon…

Great Tutorial. Works very well. However if you make a couple of changes one does not need to create a new ArchiveTemp every time one wants to zip and send:
All of the following are actions found under Library- Files & Folders. After Send Outgoing Messages, add Get Specified Finder Items and on Name chose your ArchiveTemp; then add the step Get Folder Contents and finally add Move Finder Items to Trash.

@raccbm: Thanks for the suggestion! That certainly saves a couple of steps. The reason I delete the ArchiveTemp folder at the end of the action is so that it doesn’t clutter up the user’s Desktop, but I guess you could create ArchiveTemp somewhere less conspicuous and leave it there…

Thank you for that intro on automator. I was finding that application intimidating and now it has become more friendly. It is hard to find user friendly info on how to use it.
I will try to work on a script that will allow me to save .TIFF image files (16-20MB) in .JPEG downsized to 1000×1000 max pixels and less than 1MB usable for web purposes using PSE6.
Well done.
Richard

Thanks for the Tutorial Matt, i’ve been aware for a long time that automator can make a lot of things easier, but i’ve just never gotten into it.

my question is this: is it possible to create a workflow that allows you to choose a *destination* as a variable? so, i am trying to create a workflow that asks me to select a file, and then asks me where to put it, and then sends an email out with the date/time and the file path.

i’m just getting into automator, and i haven’t yet stumbled across the way to do this.

If you use the Move Finder Items action, for example, then you can click Options, then select the “Show this action when the workflow runs” option. This then pops up a file chooser dialog when the workflow runs. However I’m not sure how to get the resulting path into a variable – the “Set Value of Variable” action sounds like it should do it, but I can’t get it to work. Hmm… If I find a way I’ll let you know!

I need your help. I run a small company where I call some customers everyday and record them. I manually create a folder and name it today’s date (Ex: 02-24-10) and save the calls in that folder. again tomorrow I do the same thing by creating a folder of tomorrow’s date. My question is, is there a way to create a folder and naming it that particular date.

Hello, I was at a training today and they had an electronic sign in sheet. We had to type in our name and then were prompted to smile upon where photo booth did its 3 second countdown and our picture was taken. (I think it was photo booth). Once everyone was signed in, during downtime, they played all the pictures…they looked like they were on a polaroid snapshot picture and the names were on the bottom of the picture. Do you know how they created this?

I’ve figured out that I need to use automator to set this up; however, I cannot figure out how they had the names, that were taken from the sign in, and placed them on the snapshot of the picture. Every time I run the slideshow from iPhoto ’09 it only has a few themes to choose from; I can’t seem to find the one that makes the pics look like polaroid pics. Any help would be greatly appreciated. Thanks.

Nice tutorial. I’m trying to figure out if what I would like to accomplish is even possible. I have access to a series of books for school, which I can print, but I have to do so chapter by chapter. With 20+ books to print, and upwards of 100 chapters per book, that’s just ridiculous.

So, I would like to create a workflow in which I could point Safari at a page, have it open individual chapter links, click on the “print” button on the webpage, then save as pdf in the print dialog box, direct it to deposit it in a folder and then string the pdfs together.

Hi, I have an Western Digital Harddrive with an encryption and unlock software on it.
I want to write an script, that automatically unlocks the drive each time it gets connected.
The script should detect, that the harddrive is attached, also directly on startup. The opens the Program “Unlock” on the harddrive, automatically type in the password and unlock the harddrive. Any ideas?

@Valentin: Your “encryption and unlock software” will need to either support AppleScript or have a command-line interface for the lock/unlock commands. You’ll then be able to automate it via Automator (or a shell script).

Of course, storing the password in an AppleScript/shell script will sort of defeat the purpose of having an encrypted hard drive.

Nice tutorial. I would get my hands on this one when time permits. Is there a way for automator to say when I click on or press a couple of key combinations, a pop up box will appear wherein I can select a proforma document and paste it automatically into Pages?

I use a web based software that downloads files to the downloads folder before we can print – hence I end up with multiple files named print.do and print-1.do and so on.
I would like to delete these files from the downloads folders prior to shutdown. Any suggestions on creating this workflow?
Thanks…