Batch Rename Your Files

Let’s dive into one of my all-time favorite Finder tips – an Automator service that lets you quickly replace text within filenames on the fly! If you’ve not yet begun using the Automator app, this is a great first project (or scroll down to download the Automator service for a quick install).

Why Use It

As a packaging artist, most of my projects include a minimum of 20 files. I employ varying hacks and tricks to generate those files quickly, but the result is usually a series of files that require some minor tweaking to their end filenames.

Alternatively, if you’re not swimming in your work files every day, you might find a need to quickly replace the filename of several recently imported photos (think of that horrific, “IMG_”), or you might want to quickly add the date to some scanned files.

Built-In Rename Vs. Homemade Automator Service

Since OS Yosemite (OS X.10), Apple has included a built-in Finder feature that allows you to quickly rename selected files and folders from the secondary menu; however, this feature can also be slightly limiting in comparison to an Automator approach. With the built-in Rename, you’re unable to specify a spacer between the date and original filename, and you’re also unable able to specify the format of the date itself (think MONTH/DAY/YEAR vs. YEAR/MONTH/DAY) – it also automatically includes the hours and seconds, which I find really annoying. Really annoying.

From this perspective, utilizing an Automator approach is beneficial, as you’re able to specify exactly how you would like the date/time to appear – right down to the date’s separator (“/“, ““, or none), as well as the spacer between the date and original filename (SPACE, “/“, ““, “_“, etc.). We’ll start with how to build your own Automator service, but the steps for using the Built-In Rename can be found directly below those instructions.

Creating Your Own Rename Automator Service

Follow the steps below to create your own batch rename Automator service, or scroll down to download the Automator script*:

  1. Open the Automator app (shortcut: CMND+SPACE+Automator+ENTER), and select Service as the document type from the menu prompt.
  2. Within the new Automator window, specify “files or folders” from the top drop down menu – this tells your Mac to enable to the service whenever a file or folder is selected. Narrow the criteria by selecting “Finder” from the second top drop down menu, so that the service is only enabled when selecting a file/folder within a Finder window.
  3. Now add the following actions from the menu options in the left sidebar (or use the search bar to quickly navigate available actions):
    1. Add Get Selected Finder Items, this tells your Mac to limit any actions following to only the selected file(s)/folder(s).
    2. Add Rename Finder Items, then specify how you would like to rename the selected documents via the newly prompted drop down menu – available options include Add Date or Time, Add Text, Change Case, Make Sequential, Replace Text, and Name Single Item. For the purposes of this Automator service, select Replace Text.
    3. From the second drop down menu, specify where you would like Finder to search and replace text within the selected file(s)/folder(s) filenames – the full name (filename and the file extension), basename only (exclude the file extension), or extension only. I prefer to edit the basename only, simply because editing a file’s extension by name only does not really convert the file from one format to another.
    4. If you prefer to search and replace text regardless of uppercase or lowercase letters, check the box next to Ignore Case.
    5. Now for the most important step IMHO – select Options at the bottom of the action’s window, and check the box next to the left of Show this action when the workflow runs. This last step ensures that each time you run your new service, a window will prompt where you can change the above settings every time you enable the service – so if you want to Change Case or Add Date or Time at some point, you have the option to without creating a new service! (I hope you’re as excited about this time saved as I am.)
    6. Save your newly created service (shortcut: CMND+S) with a name that will stand out to you from within the secondary menu options – I’ve saved mine as “Replace Text”, but you might prefer “Rename Files” or simply “Edit File Names”.
    7. To run your service, head to a Finder window and select the file(s)/folder(s) you want to rename. Prompt the secondary menu with a right click (shortcut: CTRL+select), and hover over Services near the bottom of the menu, then simply select your service and complete the options from within the newly prompted menu.

Using the Built-In Rename

  1. Select the files you would like to edit.
  2. Right click (CTRL + click).
  3. Select Rename X Items….
  4. From the newly prompted window, define how you would like to edit the filenames:
    1. Replace Text: Find special characters or a specific phrase within the filenames and replace with something else of your choosing.
    2. Add Text: Add special characters or a specific phrase either before or after the filename.
    3. Format: Reformat the filename by adding an index number, specifying a counter, or adding the date and time either before or after the filename.

While it’s nice to see that Apple has included a batch file rename service out of the box, it’s not quite as powerful as an Automator approach. It makes for quick work, but you may find yourself having to edit and re-edit until your files are named the way you like, and for that reason I recommend spending a few minutes building your own service in Automator to save yourself a few seconds in the future.

  • * If you download the Automator service, move the file to: ~/Library/Services/

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s