Five workflows for geeks
A robot programmed to do your bidding—who would pass that up? But many people think of Automator, Apple’s newest Mac-automation tool, as a tool for beginners who are too scared to learn how to use AppleScript. In fact, Automator can be quite powerful—especially when combined with other OS X features, such as Unix commands, image handling, and even AppleScripts.
Here are five useful and fun Automator workflows bound to make you the envy of all the geeks in your town. ( Click here to download all five.)
Just open Automator (in your Applications folder) to get started. Click on the library item specified at the beginning of each step, and then drag the action that follows from the Action list into the Workflow pane below any previous actions. (The relevant library items and actions for each step are indicated in bold.)
If you’d like to save a workflow, choose File: Save. At that point, if you want to make the workflow a double-clickable Finder icon (so you can run it using iCal’s alarm feature, for example), choose Application from the File Format pop-up menu in the Save dialog box.
Back up Word documents
Everyone knows that it’s a good idea to back up important files, but many people forget to do it. This workflow makes backing up a cinch; when you run it, all the recently changed Microsoft Word files in your Documents folder get compressed and then burned onto a CD. Run the workflow every week, and you’re covered—you’ll never lose more than a few days’ worth of Word work.
1. Finder: Find Finder Items This action looks for all the files on your hard drive that match certain criteria. First, click on the Where pop-up menu and select Documents, so the action will search only in your Documents folder. Next, choose Date Modified from the Whose pop-up menu (lower left), and choose This Week from the pop-up menu to its right. Click on the plus sign (+) to add another criterion. In the new row of pop-up menus that appears, set the first menu to Extension. Set the next to Is Equal To and then type
docin the text field beside that menu. The action will now find files in your Documents folder that changed this week and that are Microsoft Word files.
2. Finder: Create Archive When you run your workflow, this action takes all the files found in step 1 and compresses them into a single ZIP file. Type a name such as
Word files backupin the Save As field.
3. System: Burn A Disc This action puts the compressed file from step 2 onto its own blank CD (or DVD). Type a name such as
Word Backup CDin the Disc Name field, and then select the Append Date option so the CD’s name will indicate when you burned it.
4. Finder: Move To Trash This action moves the ZIP file created in step 2 to the Trash.
Other Ideas: If you want this workflow to back up items other than Word files, just change the criteria in step 1; you can specify any file type you desire (HTML, for instance).
To make the workflow even more convenient, use iCal’s alarm feature to schedule it to run automatically. To do this, save the workflow as an application, as described at the beginning of this article. In iCal, select File: New Event, select View: Show Info, click on the Alarm pop-up menu, and select Open File. In the dialog box that appears, select the workflow.
Get a profile of your Mac
Do all the Macs in your classroom have the latest version of OS X? Do you find yourself frequently on the phone with an Apple tech-support wiz, searching desperately for your computer’s RAM information? Although OS X includes the System Profiler utility for getting information about your Mac, it’s hard to see all its statistics at once. This workflow fetches all the profile information from your Mac and turns it into a text file.
1. System: System Profile Click on Options and turn on Show Action When Run. When you run the workflow, it will ask you which parts of your computer you’d like to have information about—software, printers, AirPort, and so on.
2. TextEdit: Filter Paragraphs Step 1 produces one big chunk of text filled with all the profile information you request—but that text contains a lot of blank lines. To strip them out, set the action’s Return Paragraphs That pop-up menu to Are Not Empty.
3. TextEdit: New Text File This action saves the text from step 2 into its own file. Type
Profile.txtin the Save As field, and then choose your Documents folder from the Where pop-up menu.
4. Finder: Open Finder Items This action opens the file for your inspection. Leave the Open With pop-up menu set to Default Application to open the file in TextEdit, or, depending on your needs, set it to another application that can read plain text, such as Microsoft Word or Apple Safari.
Other Ideas: When you’re about to call Apple for tech support, print out the profile this action produces so you can refer to it. If you run a computer lab, use the text file each machine produces to compare system statistics.
Make man pages more manageable
When studying the fine points of
uptime, the first place Unix aces turn for help is the manual pages. This workflow spares you the trouble of opening Terminal and straining your eyes to read its unhelpful text formatting. Instead, you can open any man page in TextEdit and print or save the document for easy reference.
1. TextEdit: Ask For Text When you run the workflow, this action lets you specify the man page you want to see. In the Question field, type
What Unix command would you like to learn about today?and select the Require An Answer option.
2. Automator: Run Shell Script Use this action to run a Unix command that retrieves and formats the man page for TextEdit. Choose As Arguments from the Pass Input pop-up menu. Then type the command
man "$" | col -bin the big text field (A) (see first screenshot).
3. TextEdit: New TextEdit Document This action opens the man page in TextEdit.
Other Ideas: Save a man page you use often (for a programming language such as Perl or Ruby, say) as a text file, and keep it in your Dock for easy access.
Set up a surveillance camera
If you have a recent digital-camera model, there’s a good chance your Mac can make it take pictures on cue. (The camera must be able to take photos while it’s plugged in via USB. The first action in this workflow will tell you if yours can’t.) This workflow will tell the camera to take a picture every 10 seconds, shrink it down to a small JPEG, and repeat until you tell it to stop. This can be useful in many situations—when you’re trying to figure out what your dog does while you’re away from home, for example, or if you’d like to make a time-lapse video without buying add-on software.
1. Image Capture: Take Picture This action tells the camera to take a picture. If your camera’s tight on space, select the Delete Image From Camera After Download option. If you have a capacious card in your camera, you might as well keep this option off so you have all your photos on both your camera and your Mac.
Note that this action automatically stores the snapshots in / your user folder /Pictures. If you’d like to store the pics somewhere else, add the Finder: Move Finder Items action to the workflow, and indicate where you’d like to save them.
2. Preview: Change Type Of Images This action gives you the opportunity to convert the images to a space-saving format, which is especially useful if your camera shoots in TIFF or Raw format. When you insert this action in your workflow, a dialog box appears asking whether you’d like to add an action that will copy your images before you change them. Click on Don’t Add so you don’t end up making two copies of every picture. Then, for maximum space efficiency, choose JPEG 2000 from the To Type pop-up menu if your image editor supports that format—Apple Preview and Adobe Photoshop and Photoshop Elements do. (If you’re using Photoshop, you might need a plug-in from the installation disk.) Otherwise, just choose JPEG.
3. Preview: Scale Images This action shrinks each picture’s dimensions for even more space savings. You’ll see the same warning dialog box when you insert this action in your workflow. Click on Don’t Add again. Unless you need to see each picture at a high resolution, the default of 480 pixels is probably big enough.
4. Automator: Pause Add this action to make Automator pause before taking the next picture. Type
10in the text field to make the workflow stop for 10 seconds. Before you go to the next action, save the workflow and give it a name.
5. Automator: Run Workflow To make the workflow take another picture, you need to make it repeat. This action starts it over again. From the Workflow pop-up menu, choose Other and then select the workflow you saved in step 4. Now save your workflow again.
To test your new workflow, click on the Run button at the top of the window. When you’re done taking pictures, click on Stop at the top of the Automator window.
Other Ideas: Once you stop the workflow, drag the pictures into iMovie to make a time-delayed movie.
Put a stock quote on your desktop
Your desktop can be a huge billboard for anything you like—even your favorite stock’s price, in the case of this workflow. If your screen is big enough, you should be able to see the price from across the room.
1. Automator: Run Web Service Fill in the fields as shown in the second screenshot (above); (B), but substitute your favorite stock’s ticker symbol for AAPL (Apple’s ticker symbol). When the workflow runs, it’ll go out on the Internet to get that stock’s price.
2. TextEdit: New TextEdit Document This action puts the stock’s current price into its own TextEdit document.
3. Automator: Run AppleScript Type the AppleScript shown in the Run AppleScript field (C) (see second screenshot). When you run the workflow, these commands will resize the TextEdit document to fill the screen, and zoom in on the text inside it.
4. Finder: Get Specified Finder Items For this step, you need a PNG image you don’t care about. Press Command-shift-3 to take a picture of your desktop. Find that file, which will be named something like Picture 1, and rename it Desktop_Picture.png. In Automator, click on the plus sign (+) in the Get Specified Finder Items action and select Desktop_Picture.png in the dialog box that appears. Automator will overwrite this picture with a screenshot of the TextEdit document from step 3. (This seems like a weird step, but it ensures that the next action will know where to save your screenshot.)
5. System: Take Screenshot This action takes a full-screen picture—including the TextEdit document that’s currently showing. Then the action saves the screenshot to the location you specified in step 4. (Ignore the fact that the Save To pop-up menu says Clipboard—that’s a bug).
6. Finder: Set the Desktop Picture This final action takes a picture of your stock’s price and makes it your desktop picture. Close any open windows (or press F11) to reveal it.
Other Ideas: Change TextEdit’s default font to something that looks more interesting—so the stock quote appears in the Rockwell typeface, for example. (Note: If this workflow appears to fail after you use it a few times, log out and then log back in again.)
[ Adam Goldstein is the author of AppleScript: The Missing Manual (O’Reilly, 2005) and a coauthor of Switching to the Mac: The Missing Manual, Tiger Edition (O’Reilly, 2005). ]The Unix command A to the left of the divider bar (or pipe) gets the manual, or man, page for whichever Unix command you specify. The command to the right of the pipe formats the manual page for display in TextEdit.The information in the Run Web Service action fields b lets Automator get the price of any stock. Just substitute your stock’s ticker symbol for AAPL. The AppleScript typed in the Run AppleScript field c enlarges TextEdit’s window and text for maximum visibility.