Automator: Script without coding in OSX

07Oct08

After last week’s mention of AppleScript I want to move onto something even easier and more fun to toy with on OSX. Under your applications folder, you should find a program called Automator.

It’s basically an abstraction layer over AppleScript. Just about anything you can do with Automator can be done by coding AppleScript, but it’s easier to drag some actions and set some options sometimes.

In Automator, you create workflows, which are basically just step-by-step graphical representations of programming functions. You can do things like rename files, create disk images, extract PDF text, get RSS feeds, find iCal items and more. You can even declare and use variables, run outside scripts and use system variables. Some of this stuff — even with proper knowledge of the libraries involved — would take a fair bit of programming skill to pull off.

A fairly simple example is one I use to create archives of files and folders.

My workflow

My workflow

If you create a workflow to match this (by taking action items from the left-hand Automator pane and dragging them to the right side), go to the File menu and save it as a plugin. Select Finder plugin, and give it a name like “Dated backup.”

Now, go to a folder and select some files you’d like to create a dated backup of. Right-click, go to “More” at the bottom of the menu, then go to the “Automator” item and select your plugin. Give it a second.

If all went well, a new file should appear in the folder you’re currently in, containing an archive of the file(s) you selected. It’s a useful workflow that showcases a cool part of Automator, namely how it allows you to manipulate files and folders using Finder and your script as a context-menu plugin.

There’s a bit of a lag, but I believe it’s the actual compression happening, and not an indication that Automator workflows are slower than most scripts. Even if there is some additional execution time, you’ve saved a good chunk of development time.

Tool around with Automator a bit though. I bet you’ll be impressed. I even ran across a guy who uses Automator to move tabs from Opera to Firefox. In his post, he shows off a cool trick where you can record your mouse and keyboard inputs for playback in your script, for when items aren’t nicely AppleScriptable.

Advertisements


One Response to “Automator: Script without coding in OSX”


  1. 1 More Automator: Batch renaming « Everyday Scripting

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: