Using Automator to Rename Files and Folders

01
of 05

Using Automator to Rename Files and Folders

Automator - Using Automator to Rename Files and Folders
Automator includes workflow templates to make the creation process easier.

Automator is Apple's application for creating and automating workflows. You can think of it as a way to perform the same repetitive tasks over and over.

Automator is often overlooked, especially by new Mac users, but it has some very powerful capabilities that can make using your Mac even easier than it already is.

Automator and Workflow Automation

In this guide, we'll introduce new Mac users to the Automator application, and then use it to create a workflow that renames files or folders. Why this particular workflow? Well, it's an easy task for Automator to perform. In addition, my wife recently asked me how she can rename folders full of hundreds of scanned images quickly and easily. She could use iPhoto to perform a batch rename, but Automator is a more versatile application for this task.

Automator Templates

Automator can create multiple types of workflows; it includes built-in templates for the most common workflows. In this guide, we'll use the most basic template: the Workflow template. This template allows you to create any type of automation and then run that automation from within the Automator application. We'll use this template for our first Automator process because by running the workflow from within the application, we can more easily see how the process works.

The complete list of available templates includes:

Workflow. The workflows you create using this template must be run from within the Automator application.

Application. These are self-running applications that accept input by dropping a file or folder on the application's icon.

Service. These are workflows that are available from within OS X, using the Finder's Services submenu. Services use the currently selected file, folder, text, or other item from the currently active application and send that data to the selected workflow.

Folder Action. These are workflows attached to a folder. When you drop something into the folder, the associated workflow is executed.

Printer Plug-in. These are workflows that are available from the Printer dialog box.

iCal Alarm. These are workflows that are triggered by an iCal alarm.

Image Capture. These are workflows available within the Image Capture application. They capture the image file and send it along to your workflow for processing.

Published: 6/29/2010

Updated: 4/22/2015

02
of 05

The Automator Interface

Automator - Using Automator to Rename Files and Folders
The Automator interface.

The Automator interface is made up of a single application window broken into four panes. The Library pane, located along the left-hand side, contains the list of available actions and variable names you can use in your workflow. To the right of the Library pane is the Workflow pane. This is where you build your workflows by dragging library actions and hooking them together.

Just below the Library pane is the Description area. When you select a library action or variable, its description is displayed here. The remaining pane is the Log pane, which displays a log of what happens when a workflow is run. The Log pane can be helpful in debugging your workflow.

Building Workflows With Automator

Automator allows you to build workflows without requiring any programming skills. In essence, it is a visual programming language. You grab Automator actions and connect them together to create a workflow. Workflows move from top to bottom, with each workflow providing the input for the next.

03
of 05

Using Automator: Creating the Rename File and Folders Workflow

Automator - Using Automator to Rename Files and Folders
The two actions that will make up our workflow.

The Rename File and Folders Automator workflow we will create can be used to create sequential file or folder names. It's easy to use this workflow as a starting point and modify it to meet your needs.

Creating the Rename File and Folders Workflow

  1. Launch the Automator application, located at: /Applications/.
  2. A dropdown sheet with a list of available templates will display. Select the Workflow (OS X 10.6.x) or Custom (10.5.x or earlier) template from the list, then click the 'Choose' button.
  3. In the Library pane, make sure that Actions is selected, and then click the Files & Folders entry under the Library list. This will filter all the available workflow actions to show just those related to working with files and folders.
  4. In the filtered list, scroll down and find the Get Specified Finder Items workflow item.
  5. Drag the Get Specified Finder Items workflow item to the workflow pane.
  6. In the same filtered list, scroll down and find the Rename Finder Items workflow item.
  7. Drag the Rename Finder Items workflow item to the workflow pane and drop it just below the Get Specified Finder Items workflow.
  8. A dialog box will appear, asking if you wish to add a Copy Finder Items action to the workflow. This message is displayed to ensure that you understand that your workflow is making changes to Finder items, and to ask whether you want to work with copies instead of the originals. In this case, we don't want to create copies, so click the 'Don't Add' button.
  9. The Rename Finder Items action is added to our workflow, however, it now has a different name. The new name is Add Date or Time to Finder Item Names. This is the default name for the Rename Finder Items action. The action can actually perform one of six different functions; its name reflects the function you selected. We will change this shortly.

That's a basic workflow. The workflow starts by having Automator ask us for a list of Finder items we want the workflow to use. Automator then passes that list of Finder items, one at a time, to the Rename Finder Items workflow action. The Rename Finder Items action then performs its task of changing the names of the files or folders, and the workflow is completed.

Before we actually run this workflow, there are some options for each item in the workflow that we need to set.

04
of 05

Using Automator: Setting Workflow Options

Automator - Using Automator to Rename Files and Folders
The workflow with all the options set.

We've created the basic outline for our Rename Files and Folders workflow. We've selected two workflow items and connected them together. Now we need to set each item's options.

Get Specified Finder Item Options

As constructed, the Get Specified Finder Items action expects you to manually add a list of files or folders to its dialog box. While this will work, I'd rather have the dialog box open separately from the workflow, so that it's obvious that files and folders need to be added.

  1. In the Get Specified Finder Items action, click the 'Options' button.
  2. Place a check mark in the 'Show this action when the workflow runs' box.

Rename Finder Items Options

The Rename Finder Items action defaults to adding a date or time to the existing file or folder name, and even changes the action's name to Add Date or Time to Finder Item Names. This isn't quite what we need for this particular use, so we will modify the options for this action.

  1. Click the top left dropdown menu in the 'Add Date or Time to Finder Item Names' action box, and select 'Make Sequential' from the list of available options.
  2. Click the 'new name' radio button to the right of the 'Add number to' option.
  3. Click the 'Options' button at the bottom of the 'Make Finder Item Names Sequential' action box.
  4. Place a check mark in the 'Show this action when the workflow runs' box.

You can set the remaining options as you see fit, but here's how I set them for my application.

Add number to new name.

Place number after name.

Start numbers at 1.

Separated by space.

Our workflow is complete; now it's time to run the workflow.

05
of 05

Using Automator: Running And Saving The Workflow

Automator - Using Automator to Rename Files and Folders
The two dialog boxes the finished workflow will show when you run it.

The Rename Files and Folders workflow is complete. Now it's time to run the workflow to see if it works properly. To test the workflow, I created a test folder that I filled with half a dozen text files. You can create your own dummy files by saving a blank text document a number of times to the folder you will use for testing.

Running the Rename Files and Folders Workflow

  1. From within Automator, click the 'Run' button located in the top right corner.
  2. The Get Specified Finder Items dialog box will open. Use the 'Add' button or drag and drop the list of test files to the dialog box.
  3. Click 'Continue.'
  4. The 'Make Finder Item Names Sequential' dialog box will open.
  5. Enter a new name for the files and folders, such as 2009 Yosemite Trip.
  6. Click the 'Continue' button.

The workflow will run and change all of the test files to the new name plus a sequential number appended to the file or folder name, for example, 2009 Yosemite Trip 1, 2009 Yosemite Trip 2, 2009 Yosemite Trip 3, etc.

Saving the Workflow as an Application

Now that we know the workflow works, it's time to save it in the form of an application, so we can use it any time.

I intend to use this workflow as a drag-and-drop application, so I don't want the Get Specified Finder Items dialog box to open. I will just drop files onto the application's icon instead. To make this change, click the 'Option' button in the Get Specified Finder Items action and remove the check mark from 'Show this action when the workflow runs.'

  1. To save the workflow, select File, Save. Enter a name for the workflow and a location to save it to, then use the dropdown menu to set the file format to Application.
  2. Click the 'Save' button.

That's it. You've created your first Automator workflow, which will allow you to easily rename a group of files and folders.