Rename batches of files
Mac Tip #281/21-March-2007
Last week’s Automator tip showed how to resize photos, but Automator is useful for a great deal more than that.
Another task I often need to do is to rename loads of files. For example, I sometimes prepare a batch of about 20 photos for the Karori Wildlife Sanctuary’s website. I receive the photos with long names, such as:
17a Wetapunga release 11-2-07 AB D28F5394.JPG.
That’s way too long. Moreover, it’s better if filenames for photos going on the web are all lowercase and don’t contain spaces. I need to rename the photos with that in mind.
Add actions to the workflow
Select the photos in the Finder, open Automator, and follow the first two steps from last week’s Tip: In the Library column on the left select Finder. From the Action column in the middle select
Get Selected Finder Items and drag the action into the large, empty Workflow area on the right.
Copy items as a safeguard
With Finder still selected in the Library column on the left drag Rename Finder Items to the Workflow. As explained last week, an alert appears offering to duplicate the photos. If you decide to Add the Copy Finder Items step two actions are added to the Workflow, rather than just one.
For the Copy Finder Items action choose the destination for the copied files. They need to be copied to a different folder from the folder containing the source files you’re working with. I have a folder called ‘renamed’ that I choose as the destination.
The Rename Finder Items action has many options, so choose Change Case to lowercase, including the extension, if you want the
.JPG extension to change to
To remove spaces I need another instance of the Rename Finder Items action, so I drag another copy of it to the workflow. This time there’s no alert, as I’m already copying my photos in a previous step.
I choose the Replace Text option, enter a space in the Find box and Replace with a hyphen. This replaces the spaces in the filename with a hyphen.
Finally, so I can check what happened after running the workflow I select Automator in the Library column, and drag ‘View Results’ from the Actions column to be the last step in the Workflow.
Then I run the Workflow. Afterwards I check my ‘renamed’ folder and see that indeed I have a second copy of my photo; the filename has been changed to lowercase and spaces have been replaced by hyphens.
There is still one problem remaining: the filename is too long. This is an area where Automator has shortcomings: I couldn’t find a way to automatically chop off anything after about the first 10 characters.
A Better Finder Rename
Since renaming batches of files is something I do very often, I actually invested years ago in a magnificent piece of software called A Better Finder Rename (US$20). It has dozens of options for renaming, and paid for itself in one use.