Start a hosting plan from $3.92/mo and get a free year on Tuts+ (normally $180)
It can be cumbersome to manually resize hundreds of photos, or perform some other repetitive task one-by-one. Fortunately, OS X comes equipped with a much more efficient way of performing common, tasks: Automator. In this tutorial, we're going to take a look at the basics of Automator and build up our own workflow.
Welcome to Automator
Automator is a stock app in your OS X installation that's all about automating tasks and workflows for you. It's a fairly versatile tool that can be used for a lot of things, but the fundamental setup of an Automator document is a workflow of actions that can be run without your intervention.
The fundamental setup of an Automator document is a workflow of actions that can be run without your intervention
In this tutorial, we're going to keep things fairly basic and put together a workflow that grabs some images, resizes them and then puts them into a new iPhoto album.
The most basic workflows are made up of predefined actions that can be dragged into your workflow, but we'll also take a look at some of the more advanced functions, such as using variables to create dynamic outcomes and even let Automator record our actions so it can repeat them later, without your intervention.
Step 1. Creating an Automator Document
When you open up Automator for the first time, you'll need to select a type of document that your workflow will take place in. There's a selection available, but the two we're really interested in are "Workflow" and "Application".
An application is self-running, and doesn't need to be opened in Automator to be ran.
What's the difference? An application is self-running, and doesn't need to be opened in Automator to be ran. If your workflow deals with items or files, you simply need to drag-and-drop files onto the app in order to run the workflow, meaning it's useful for doing things like image manipulation without needing to even open an application. A workflow is very similar, but it runs inside Automator and selects entities to deal with through special actions. We'll get more in depth with that in just a moment.
For the sake of this tutorial, we'll be making a workflow.
Choosing a document type in Automator.
When you launch into your document, you'll be presented with a blank canvas in which to build up your workflow. Additionally, you'll get a long list of actions that can be dragged-and-dropped into workflow to build it up.
Step 2. Understand What We Want To Do
Before we go any further, it's important to understand exactly what we want to achieve with Automator. By first outlining the steps it would take to achieve our outcome manually, we can better translate this task into a workflow in Automator.
By first outlining the steps it would take to achieve our outcome manually, we can better translate this task into a workflow
For the sake of this tutorial, we're going to work with some images, selecting them, manipulating them and even putting them into an album in iPhoto. Of course, photos are just one small aspect of what Automator can do, but that's what we'll use as an example during this tutorial.
- Pick up the images we have selected
- Resize them to a specific pixel width
- Put them into a new iPhoto album, with a dynamic name
Step 3. Selecting Files (if applicable)
The first thing we're going to want to do in our workflow is to pull in the files that we want to apply our batch tasks to. In the case of our example, these files will be photos, selected in iPhoto. Alternatively, if the files weren't photos, we could select them with an action like "Get Selected Finder Items" which pulls in files selected in Finder, including on the desktop.
Most file types will have their own actions to select files, most of which will appear if you simply search for "get".
The "Get Selected Finder Items" action in Automator, which will pull in files selected in the Finder app to the Automator workflow.
Actions can also have options, which will further tweak what exactly they do. The "Get Selected Finder Items" action that we're using doesn't have any that really need to change but, say, the "Get Selected iPhoto Items" does. In that action, we have the choice of pulling in the selected albums or photos, toggleable through a drop-down field.
Step 4. Taking Action
In our photo manipulation workflow, we're going to start with some pretty basic, constant actions to apply to the photos we have selected. By using the file tree pane on the far left of Automator, we can filter down the actions to just the relevant ones.
One of these low-level actions is "Scale Images", which will resize the specified images we pulled into our workflow. When we factor this into our workflow, it'll always do the same thing; resize our images to the size specified in the action's options.
Of course, "Scale Images" is just one action, and not one that you need to have in your workflow. Naturally, you can use different actions and build up workflows full of many of them.
An example of a very basic workflow that, when run, would scale selected images to 480px.
While, for some very basic tasks, especially those that deal with file manipulation, the predefined actions are useful, there probably will come a time where you want to translate an action into your Automator workflow that isn't available as standard. This is where the red recording button comes into play.
Automator can actually observe, on command, the things you do and then place those steps into your workflow.
Automator can actually observe, on command, the things you do and then place those steps into your workflow. So you can do something, save it into your workflow and then Automator will retrace those steps when you run the workflow next.
This is quite a flexible feature. For example, if you have a specific routine when you first start up your Mac, you can record that, package it in an application and, next time you boot up, let Automator get things setup just the way you like it.
This is a sample recorded workflow that opens up a few applications from my dock and then even puts one into full-screen mode for me.
Remember when we talked about constant actions? When we setup our images to resize, every time they would scale to the exact same size that we defined in Automator. However, we can also use variables to change specific aspects of the outcome to be dependent on our files.
We can also use variables to change specific aspects of the outcome to be dependent on our files.
To keep things simple, we'll just use some of the preset variables, things like the current date, user, etc. What this means is, when we tell Automator to move our photos into a new iPhoto album, we don't need to give it a standard title. Instead, we can build one with variables so the album's name can reflect, say, the date. This is as easy as dragging in a variable to where you'd otherwise type.
A simple use of variables, pulling in the current year into the album's name.
Step 5. Running
Now that we've constructed our workflow, it's time to save them so we can run them when desired. If you created a workflow, you need only save the document as normal and then open it, when needed, and hit the "Run" button. If you produced an application, you save it in exactly the same way but, when it's time to run, you simply need to open the exported app itself (or drop files onto it, if applicable).
The Completed workflow.
How Do You Use Automator?
That's our look at the basics of Automator. It's an extremely powerful tool that's easy to overlook and underestimate. Be sure to give it a shot the next time you're faced with a tedious and repetitive task.
We'd love to hear about some of ingenious workflows that you've used Automator to accomplish, so leave us a comment below!