Along with Dashboard and Spotlight, Automator was one of the most highly advertised features of Tiger. But since Tiger's release, things seemed to have slowed down a bit. Are we so mesmerized with Dashboard and Spotlight that "Otto" has fallen by the wayside and we're all unknowingly missing out? Let's take a closer look at Automator and see if it can really change the way we do our daily work.
Unlike "the paperclip guy" you might have known in a former life, Automator is its own stand-alone application. Otto doesn't dance around on your desktop and offer you frivolous advice; instead, he makes it easy for you to streamline a series of tasks by helping you to create a workflow.
Workflows consist of a series of actions. An action is a purposefully simple little program that optionally takes input, performs a very specific task, and then passes the output to another action. If you've worked on the command line before, this type of architecture should remind you of the familiar pipes and filters architecture. It's simple, but can also be very elegant and powerful.
To simplify some of the daily drudge with Automator, you need to determine if the actions you'll need to make it happen are available. Without the actions to accomplish your workflow, Automator can't do much for you. To get started with Automator, take a moment to check out what actions are bundled by opening up Automator (located in you Applications folder, or type "Automator" in Spotlight) and then browse through the actions available at Apple's Automator Actions site.
If you've ever programmed or scripted before, you probably have predisposed expectations of what you want Automator to be able to do. When I first thought about Automator, I envisioned a very simple drag-and-drop GUI interface to some subset of AppleScript, where each action would really just be a generalized snippet of AppleScript or some other compiled code. Clearly, the emphasis would be on the stream of actions in the workflow but there would also be some room for basic "if ...then..." logic and iteration.
|
Related Reading
Mac OS X Tiger Pocket Guide |
In reality, Automator is actually quite a bit more primitive than what I'd envisioned. While actions can virtually be any kind of code you want, there isn't any kind of conditional logic or iteration involved between the actions--at least not yet. The closest you'll come to branching and jumping around is with the crafty inclusion of scripts in your workflows. Sometimes including scripts works out quite well, but there are other times when going to this length seems to defeat the whole purpose of using Automator in the first place. But as we'll see, there are still plenty of times when Automator can get mindless jobs done before you could have even compiled an AppleScript.
Let's get some work done with Automator. An annoying routine task that many of us face these days is renaming images to something more sensible than what we normally get from our digital cameras or from out on the web. Since Spotlight comments are very helpful for adding additional metadata that allows you to easily find the images in a search, let's add some of those too. The comments will spare us from otherwise cluttering up the filename.
Our workflow requires only five steps. Automator actions are grouped by application, but you might find it easier to follow along by viewing one long alphabetical listing of them. Click on the Applications folder to get that listing.
When you open up Automator, you'll be greeted by an intuitive interface. Drag over a series of actions to create a workflow.
For each of these steps, drag the specified action onto the workflow pane.
Create a workflow to rename and tag images with Spotlight comments.
|
When you're done, save your workflow (source available here), and then resave it as an application so you can run it as a stand-alone app. Take it for a spin and see what you think. For a few minutes of fuss, we have a useful workflow that can make your day go by just a little bit easier.
Save your workflows as stand-alone applications by changing the default value through File --> Save As
With our example involving iPhoto, things worked out pretty well because we had the specific actions needed to get our work done. One subtlety worth pointing out involves the transition between Step 3 and Step 4 of the workflow. Step 3 passed out "iPhoto items" and Step 4 accepted them even though it was really expecting "Files/Folders." For these two actions to work together, something called a "conversion action" conveniently took place behind the scenes and transformed the data type for us. Intuitively, we know that the photos are just files stored on a disk, so a conversion action like this is almost to be expected.
Unfortunately, however, there are situations where we won't get the luxury of conversion actions unless we write or scrounge them up ourselves. These are the times when you'll have an idea for a workflow that should conceptually work, but actions don't fit together because of data type mismatches. For example, it might be very convenient to snap a screenshot and automatically email it to someone. Conceptually, you'd think that there are just two actions involved: snap the image and pass it into an email. A workflow like this might be useful for helping a friend to diagnose a problem they're having. Here's the broken action you'd see if you tried to construct such a thing in Automator for the first time.
Although conceptually elegant, this action doesn't work because the New Mail Message action won't automatically insert image files as attachments. Note the red letters on the actions that aren't piped together.
Although not as elegant as our two-step pipe dream, you can still work around the apparent limitations without having a special conversion action. Here's one way of doing it.
|
Note that there isn't a single action to create a new mail message with a set of attachments all as one step. You actually have to open a message and pass the attachments to the message as separate actions. Here's how it all looks in Automator:
You can email a screenshot, but you'll have to fight the style guidelines to do it.
As you can see, you have to fight the style guidelines pretty hard to make something like this happen, but it's possible and wasn't too difficult to do in this case. You can get the workflow for emailing a screenshot here.
Streams of discussion all over the net seem to point to the same common complaint with Automator: there just aren't enough actions available to take care of routine business. While Automator comes packaged with almost 200 actions out of the box and you can find more out at Apple's Automator Actions site, you'll find that there's still room for plenty of work to be done. Lots of it. Apple could give Automator a tremendous boost if it provided an update with 500 or so additional actions for the core applications that come packaged with Tiger. For example, open up Automator's System library and take a look. On Tiger 10.4.2., there's a whopping seven actions. I'm sure we can all think of five or ten times that amount that would be handy to have available. The same goes for just about all of the other core applications, although some are outfitted better than others.
There's a lot things that Automator could do if only the actions were available to create useful workflows. As things stand right now, you'd have to be pretty darn crafty, and do some scripting and Cocoa voodoo to create all of the actions you'd need to truly automate most of your routine workflows. Unless you are a developer just looking to make the world a better place, you probably don't have the time to develop a series of custom Automator actions to accomplish workflows that you could continue doing manually.
But alas, Automator is still just a tyke and it's still got a lot of growing to do. By pinging the developers of our favorite apps whenever we need an action that would make our lives easier, we can do our part to see that cute little robot grow up. Apple has a designated line just for Automator feedback, which would be a good place to vent your frustrations when you find that Automator could use a little more Cupertino pizzazz. For that matter, any serious developer is likely to listen to you if you're a paying customer, or you'd otherwise be one if the right actions were available. In the end, it all goes back to the same old supply and demand relationships that work everywhere else in the world. For some interesting reading, check here to see the case Apple makes for developing Automator actions and here to read about Bare Bones' decision to be an early supporter of Automator.
If you need actions for open source software, web-related tasks, or you just want to jump in and immortalize yourself forever in Automator glory, you can develop and distribute your own actions. There are a slew of resources out there to get you up and running. Matt Neuberg's Write Your Own Automator Actions tutorial is a good starting point that'll set you up for moving on to Apple's definitive reference: the Automator Programming Guide.
Matthew Russell is a computer scientist from middle Tennessee; and serves Digital Reasoning Systems as the Director of Advanced Technology. Hacking and writing are two activities essential to his renaissance man regimen.
Return to the Mac DevCenter.
Copyright © 2009 O'Reilly Media, Inc.