Automator is one of the my favorite new features in OS X; it allows non-technical users to create seemingly complex programs to handle mundane tasks. Not only that, but these new programs can then be hooked into Automator’s contextual menu in the Finder via a simple Save As, and you have the beginnings of the ultimate power tool. As such, expect to see a number of Automator-related tips here in my blog, including today’s entry.
Let’s say you work in a business where you get a number of different project files from a number of different clients. As the files come in during the day, you keep track of them using a system of named and date-stamped folders, with a numerical sequence number for each project:
- Client ABC | 2005-09-15_1
- Client ABC | 2005-09-15_2
- Client ABC | 2005-09-15_3
- Client DEF | 2005-09-15_1
- Client DEF | 2005-09-14_1
To further differentiate clients, you also use Finder Labels to color-code your top seven clients (as there are seven colors available). Your system works great, but creating the folders is a time-consuming process. Enter Automator, which can make the task nearly effortless.
Launch Automator (in the Applications folder), and then click on the Finder entry in the Library column. With the Finder selected, drag each of the following entries from the Action column to the work area on the right; place them in this order, from top to bottom:
- New Folder
- Rename Finder Items
- Rename Finder Items— yes, drag it twice!
- Label Finder Items
You now have the shell of your Automator action for a given client. Here’s what each command does, and how to customize the settings for a given client. I’ll use the settings necessary to create folders named as shown above. If you’d like a different naming scheme, just change the various values as needed.
Step 1: New Folder
This action creates a new folder in the Finder. In the Name field, enter the name that you’d like the folder to have. In my case, I entered “Client ABC |”—notice that there’s no trailing space after the pipe (vertical bar). Set the Where pop-up to the desired location for the new folder. Unfortunately, Automator doesn’t offer a “In the current folder” location option, so you’ll have to pick from one of the pre-defined save points, or use Other to pick a specific location. I left mine set to Desktop, which makes it easy to then drag the finished folder to its desired final location.
That’s how the completed action should appear with the edits in place.
Step 2: Rename Finder Items
This first Rename action will be used to append the date to the new folder you just created. Set the first pop-up to “Add Date or Time,” then set the remainder of the values as shown below:
Note that you should make sure that Year comes first in the Format pop-up—this will insure that the Finder sorts these items properly, in date order. With these settings in place, the folder will have ” YYYY-MM-DD” appended to its existing name.
Step 3: Rename Finder Items
This second instance of the Rename action will append the project number to the folder’s name. Here you actually have two options. You can name the folders as I’ve shown above, which will work fine—at first. However, if you are moving the new folders into another location, you may run into a duplicate folder name issue down the road. For example, you create a “#1” folder, then move it to its permanent home, then run the script again. When you do so, you’ll get another “#1” folder. Try to move it, and the Finder will tell you it’s a duplicate. But if you’re going to leave all of the client folders in the same folder where they were created, this method is fine to use, and is the easiest to read. Here’s how to set up this Action to use sequential numbers:
This will put an “_n” at the end of the folder’s name, where “n” is the numerical sequence number.
For my purposes, I decided to add a unique value to the end of each folder’s name. But how do you make sure the number is unique? Simple; Automator will let you append the number of seconds since 12 midnight to the name. By doing this, I can move the finished folders to any destination, and never have to worry about duplicate names. To append the seconds instead of a sequence number, set the first pop-up to Add Date or Time, and then use these settings for the other values:
This leads to a folder with “_nnnnn” appended to its name, where “nnnnn” is the number of seconds since midnight.
Step 4: Label Finder Items
This one’s quite easy; just pick the color you’d like to associate with the given client. Once a color is chosen, new folders will be created with that label attached:
Testing the Action
Now would be a good time to compare your action with this screenshot of my completed action. They should either be identical, or they should only vary in those ways that you changed—file names, formats, etc. Once you’re sure you’re ready to go, click the Run button. The result should be a named and labeled folder in the location you specified.
Putting the Action to Use
The best way to put this action to use is to make it a Finder Plug-in. Select File: Save As Plug-in, and give your plug-in a name (“Client ABC Folder,” for instance). After saving, you can control-click in the Finder, then select Automator: Client ABC Folder from the pop-up menu, and you’ll instantly have a new folder for client ABC in the location you chose in the script. Using the pop-up menu, you can easily create any number of folders in a hurry:
But why stop with just client ABC? Modify the action as necessary for your other clients—probably just chagning the label color in the last item—and save each modified version as its own Finder plug-in. Now you’ve got seven easy-to-use, always available, commands to create your specially named and labeled folders.
The scenario in this example may strike you as a bit contrived; that’s OK if it does. The bigger picture is that Automator makes it very easy to create your own customized Finder folders. Play around with renaming and labeling, and you’ll find you’ve got a powerful timesaver at your fingertips, regardless of your actual workflow needs!