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/

Keep Your Desktop Clean (with Hazel or Automator)

Like so many other Mac users, I am guilty of saving files to the Desktop. The shortcut (CMND+D) is so much easier than selecting a folder from the sidebar! Which saves me so much time – ALL the time – time I’m able to use to go back and organize the files sitting on the Desktop.

Except, not so much. The reality is that by the time I get around to organizing those files, I’ve mostly forgotten their original purpose. And I hope you weren’t expecting me to keep a list of any graphics files that might link to Desktop files, because there’s no way I’m going back to correct those links until it’s an issue.

Er… I think you can see the issue with saving files to the Desktop. Whether you believe files sitting on the Desktop really do slow your computer down, or you’re also finding that the Desktop is a less than ideal Inbox, automation is here to help!


Screen Shot 2016-04-09 at 10.25.51 PM

Hazel is an automation app that sits in your Mac’s System Preferences. The beauty of this app is that it simplifies the sometimes daunting power of Automator, and it does this by allowing you to create a series of rules that it applies to folders you instruct it to monitor.

Keeping your Desktop clean with Hazel is as simple as five steps:

  1. Add the Desktop folder to Hazel.
  2. Add a new rule to the Desktop folder.
  3. Set the first criteria drop down to Any File, since you want all files on the Desktop to be moved.
  4. Under Do the following… set the action drop down menu to Move, then select the folder you want all Desktop files moved to from within the newly prompted drop down menu.
  5. Select Ok.

Conversely, there may actually be specific files that you want to always stay on the Desktop, such as alias folders. Protecting these files is as easy as ensuring that the very top drop down menu in Hazel is set to All, then add a new criteria rule that specifies Kind with the condition is not and the file type Alias (see figure above for reference). This additional step simply tells Hazel to look for any file that is not an alias file, and that file is the one to which the action will apply.

For my purposes, I have created an Inbox folder inside my user folder, and that is where Hazel moves all my Desktop files. Hazel then monitors the Inbox for additional rules, such as moving all image files into a specific folder, or grouping similarly named PDFs into particular folders, etc.

I’ll share what my Inbox folder’s rules look like in the future, but for now feel free to download my Desktop’s Hazel rule for convenience.



The same effect can also be reached by utilizing Automator’s built in Folder Action capabilities, though it requires a few more steps than Hazel.

Follow the steps below to replicate the Hazel rule created above, or scroll down to download the Automator script*:

  1. Open the Automator app (shortcut: CMND+SPACE+Automator+Enter), and select New Document from the menu prompt.
  2. Select Folder Action as your new document type.
  3. Within the new Automator window, specify Desktop from the top drop down menu – this tells your Mac which folder to monitor for file/folder changes. Now add the following actions from the menu options in the left sidebar (use the search bar to quickly navigate action options):
    1. Add Find Finder Items, then specify the Desktop folder from the Search dropdown menu. Here, you can specify the types of files you want Automator to move – or not move. I instructed Automator to find all files except alias files/folders.
    2. Add Move Finder Items, then specify the new folder you wish to house files saved to the Desktop folder from the To dropdown menu.
    3. Save your script (shortcut: CMND+S).**
  4. Technically we should be able to stop here, since our very first step instructed Automator to monitor the Desktop folder; however, Automator does not always perform properly during a script’s first run.
    1. To ensure that our script does work, direct your Finder window to the Desktop folder.
    2. Enable the secondary menu (shortcut: CTRL+select) and hover over the Services option.
    3. Select Folder Actions Setup….
  5. Within the newly prompted Folder Actions Setup window, follow these final steps to ensure your new Automator script runs indefinitely:
    1. Ensure that Enable Folder Actions is checked at the top.
    2. Select the left + button to add the Desktop folder to the left area – telling your Mac to monitor the Desktop folder.
    3. Finally, select the right + button to add your newly created Automator script to the right area – telling your Mac to apply the script to your Desktop folder.


  • * If you download the Automator script, move the script to the path below and then complete all steps beginning from Step 4.
  • ** You can find the saved Automator script at: ~/Library/Workflows/Applications/Folder Actions/

Additional Reading