Apple’s Automator Workshop
Dr. Luanne Fose, InstructorCal Poly, The Center for Teaching and Learning
Background
Apple has been trying to get people to program for a really long time. Apple introduced Apple Script, which was Apple’s attempt to make programming available to the masses but it failed miserably. Apple Script was really a programming language that wasn’t that easy to learn, and it wasn’t very powerful (because they were trying to make it easy to learn) so what you ended up with was a program that programmers didn’t want to use because it wasn’t flexible enough and real people didn’t want to use it because it wasn’t easy to learn. Apple Script is still around and much more powerful than it was in the past and much easier to learn than programming languages such as Basic or C. In an effort to bring programming to the masses, Apple has now introduced Automator.
Basic Parts of the Interface
Automator’s interface is similar to Apple’s Address Book or iTunes applications. You can select an application choice from the Library and see the set of Actions associated with it. If you click on an Action, you can see the description of what it does in the window below. You also have the choice to Run or Stop your actions with the Play and Stop buttons in the upper-right corner of Automator. This feature allows you to try out your Workflows why you are building them before you save them out as a plug-in or as an application.
Create a Script to Convert .PNG Files to .JPGs
Note: Mac OS X’s default for saving screenshot image files is PNG when you use
Command-Shift 3 or Command-Shift 4 to grab a screenshot. Most people would prefer to have their screenshots saved as .jpg
1) Open Automator. In the Library column, click on Finder Library > Get Selected Finder Items. Press Return and you will see the action move over to the Workflow Execution window to the right. (You can also drag the action over to the Workflow Execution window.)
Note: The two actions join up in a specific way. An action can have input (data that feeds into it) and output (data that it produces). For one action to succeed another, you usually want the data produced by the first to be fed to the second. The join arrow between the actions in Workflow shows this happening.
3) Finder Library > Move Finder Items. Press Return. Details: To: Desktop. Place checkmark next to “Replacing existing files.”
Creating a Plug-in
Obviously, you can save this out as a stand-alone application but you can also save out the workflow as a Finder plug-in that you can use by right-clicking (Control-clicking for those of you who don’t have a 2-button mouse) and using the Automator menu and submenu.
1) Select Save As… > Save as Plug-in
2) You can select different types of plug-ins from the pop-up menu, but we’ll pick Plug-in For: Finder
3) Save this script with a descriptive name such as “Change PNG to JPG”
4) Right-click in the Finder and select workflow (in this case, select the workflow off of the
Automator submenu that is called “Change PNG to JPG”).
Note: Whatever is currently being processed in a workflow shows up in the Finder menu at the top of your computer screen as the workflow is being processed.
Create a Script to Convert a Text Document into MP3
& Sync to Your iTunes and Your iPod
1) Open Automator. In the Library column, click on Finder Library > Ask for Finder Items. Press Return. Details = Type: Files; Start at: Documents; Prompt: “Select a Text or Word Document:”
2) Automator Library > Ask for Confirmation. Press Return. Details = Top text box message, type the following: “The text document you selected will open next.”
Explanation: “Warning: Do NOT close the text document until the Automator process has completed. While SpeakIt! Is running, it is important that the text document remain open.” Retain the Cancel and OK buttons (but you could click on them and change the text of these buttons if you wish.
3) Finder Library > Open Finder Items. Press Return. Details = Open with: TextEdit.app 4) TextEdit Library > Get Contents of TextEdit Document. Press Return.
5) TextEdit Library > Text to Audio File. Press Return. Details = System Voice: Victoria;
Save As: “Speakit Audio File”; Where: Desktop
6) iTunes Library > Import Audio File. Press Return. Details = Using: MP3 Encoder; checkmark next to “Delete source files after encoding”
8) iTunes Library > Eject iPod. Press Return.
9) Save out as Finder Plug-in called “Text to iPod Audio” Right-click in the Finder and select the plug-in workflow (in this case, the one called “Text to iPod Audio”) from the
Create a Script to Crop Selected Images from iPhoto and
View with Preview
1) iPhoto Library > Get Selected iPhoto Items. Press Return. This action requires you to open iPhoto and Shift-Select or Command-Select whatever images you want to crop. 2) Finder Library > Copy Finder Items. Press Return. Details: To: Desktop
3) Preview Library > Crop Images. Press Return. From pull-down menu, select: “To Dimensions” Choose Scale before crop: Scale to Width. From this Options menu, select Show Action When Run. This will cause Automator to do all the previous steps and then bring up a dialog box so you can select the width and height you want the images cropped to each time.
4) Preview Library > Open Images in Preview. Press Return. This will show you the images as the completed cropped version in Preview. The changed images with new dimensions will be on the desktop to use however you desire. One of the nice things about this workflow is that your original images remain untouched in iPhoto since a copy of the images was made to the Desktop.
Create a Script to Rename & Renumber Photos Selected from
Desktop
Note: For this exercise, we will use the folder of images called “Yosemite Images for Automator Class,” which has been placed in a folder on your Desktop
1) Finder Items > Get Selected Finder Items. Press Return. This action requires you to already have photos from iPhoto or some other source dragged to the Desktop and to have these items selected with Shift-select. (Open Yosemite Images for Automator Class and press Command-A for Select All)
2) Finder Items > Rename Finder Items. Press Return. From the pop-up menu that defaults to Add Date, select Make Sequential instead. Select Add number to new name and type in the new name you want in the textbox. Select the following: Place number after name. Start numbers at 1. Separated by dash. Checkbox on Make all numbers 3 digits long. Click on the Options arrow and select Show Action When Run
so that you can fill-out this dialog box differently each time you use the workflow based upon your desires at the time.
3) Save this version as a workflow called “Rename Photos on Desktop” and also save it as a Finder plug-in.
Create a Script to Rename & Renumber & Mail Photos as
Attachments Selected from Desktop
Note: Add the following actions to the script we created above in order to be able to mail these photos as attachments within the workflow.
To the previous workflow, add the following:
1) Mail Library > New Mail Message. Press Return. Be sure that the Options choice is set to Show Action When Run.
2) Mail Library > Send Outgoing Messages. Press Return.
Note: You must be using Mac Mail as your default application (not Entourage or some other email program) for this workflow to perform properly.
Troubleshooting Your Workflows
There are a variety of ways to test your workflows as you run them: One way is to go to the
View menu and select Show Log. As you run the program, a log will appear below the main Automator window showing you how it is executing each action. Another way is to go the Library and within the AutomatorLibrary, select View Results. Insert this View Results action between any actions where you want to see what is going on.
Removing Finder Plug-ins
If you have saved some workflows as Finder Plug-ins and later decide you don’t want those to show up in the Finder Automator menu anymore when you right-click within the Finder, you may remove them by going to the following location in your user home area and throwing away whichever ones you want to discard:
~/Library/Workflow/Applications/Finder
Additional Automator Actions for Your Automator Library
A simple Google search for “Automator Action Scripts” will bring up all sorts of actions scripts (some free, some for a price) that you can import into Automator and use. There are some excellent actions for Photoshop users, iWeb users, podcasters, etc. To import them into Automator, simply choose File > Import Actions within Automator.
Here are some of the best we’ve found:
•
Apple’s Automator Action Scripts Downloads web page. Automator actions are added weekly to this web site. There’s some great stuff here!http://www.apple.com/downloads/macosx/automator/
•
Automator World: http://www.automatorworld.com/•
Macscripter Actions and Workflows http://www.automatoractions.com/Want to Learn More?
•
Review Other Automator Workflow Examples on the Web:http://automator.us/examples.html