Jesus Vigo illustrates the power of Mac Automator by sharing three common tasks you can set up. Purge files, map drives, and create custom automations by following these steps.
As a computer user, there are always tasks that require our attention to get accomplished. Simple, yet repetitive tasks that we've grown accustomed to performing like emptying the trash bin, batch processing photos to resize or change the file type, or even running complex scripts which execute certain commands. Entering all these commands or remembering to actually do the tasks can take away precious minutes from your work, and over time, they amount to hours, maybe days, weeks (or even months) of lost productivity!
Enter Automator. Built-in to every version of OS X since 10.4 (Tiger), Automator is Apple's answer to system automation, best described as a tool that helps to "accomplish time-consuming, repetitive manual tasks quickly, efficiently, and effortlessly". Automator takes out some of the hard work in creating custom bash commands or Applescripts by breaking down each action to be performed as a module that you piece together via drag and drop, along with other actions to create a workflow that, if chained together correctly, will run the desired command(s) and achieve the desired effect.
Below are a few real-world uses to help you and your end-users spend more time working smarter, not harder.
Purge select image files from a folder while leaving all other files untouched.
- Open Automator and select "Workflow" as the type of document.
- Under the Library section, click on Files & Folders and select Get Specified Finder Items from the list. As an alternative, one can simply drag and drop files (or folders) from the Finder window onto the Automator actions pane, which will automatically add the specified finder items action as well. (See Figure A)
- With all the items selected, drag and drop the Move Finder items to Trash action, placing it below the previous action (Figure B).
- Before saving the workflow, click on the "Run" button located on the top-right to execute a test of the actions in the workflow.
- After ensuring that it works as desired, select File>Save and give the workflow a name; specify a location where you wish to save the file.
Click to enlarge.
Click to enlarge.
Now that the workflow has been saved with the .workflow extension, just double-click the file to open it in Automator and click the "Run" button as performed in step #4 when you wish to execute the actions.
Mount shared folders from a server (or remote computer) as a network drive
Click to enlarge.
- Open Automator and select Workflow as the type of document.
- Under the Library section, click on Files & Folders and select Get Specified Servers from the list (Figure C).
- Drag and drop the selection over to the right where it says "Drag actions or files here to build your workflow".
- Click on the Add button and enter the server address in the box. (Remember, when selecting Apple shares, prefix the IP address or URL with afp:// and for Windows-based shares, smb://). Once complete, click OK. (Port numbers may be appended, if needed, but are not required).
- Next, go back and drag and drop the Connect to Servers action, placing it under the previous action.
- Once you're done adding shares, go to File>Save and give the workflow a name; specify a location where you wish to save the file and lastly, change the file format to Application, then click "Save".
You've now created a workflow that will establish a connection with the selected servers and create a mounted share on the desktop simply by executing the workflow app.*Tip: Want to fully automate this process? Add the MapDrives.app file you created in Automator to the login items for your user account (Figure D). Remember to enter your credentials and tick the "remember this password in my keychain" on first connect. Now, upon logging on, the app will run in the background and map the drives automatically without user input.
"Watch me do" WorkflowThe "Watch me do" workflow is arguably the most powerful and versatile action available to the user through Automator. This action truly knows no bounds as it is capable of "learning" the way one works and can step by step copy the exact motions taken to perform a task (or various tasks). Please note that this much power is not without its downside, unfortunately. Since it will mimic your actions, if the actions taken are wrong, the resulting workflow will produce an error, not work as intended, or worse, may cause irreparable damage to the system files (especially if Terminal commands or scripting is invoked). As is the best practice when dealing with a testing environment, do not run tests on production machines!
- Open Automator and select the type of workflow you wish to create.
- Click on the "Record" button, located in the top-right corner (Figure E).
- The Automator workflow screen will hide itself. Do not worry as this is normal behavior. The window will be replaced with a small Automator box allowing one to view the desktop in order to execute the desired commands, while the Automator program records all the steps, keystrokes, etc. involved in performing the action(s) (Figure F).
- Once completed, click the "Stop" button in the Automator box and all recorded actions will appear in order within the actions pane in the Automator window.
- From this point, feel free to add or modify any action(s) in order to get the workflow just right.
- Once edited, go to File>Save and give the workflow (or service) a name; specify a location where you wish to save the file.
Click to enlarge.
Workflows can be set up as .workflow files that can be modified, as needs change. They can also be initially set up as a system service and made available to other applications via the "Services" context menu, available from an application's drop-down menu. They can be set as triggers for calendar alarms in iCal or Folder actions which can then be assigned to specific folders to perform a variety of customized actions to suit your needs. Automator can even export a workflow as a full-fledged .app that will run the specified commands when executed. Exported files can be hosted on servers or deployed like any other application, making it truly portable. The limit is your imagination (and the applications installed) since certain apps (i.e., Apple Remote Desktop) include additional functionality to Automator.