Now, I know a lot of us have scripts we’ve made to rename files and those certainly do a great job, for some very specific cases. But why mess around with writing a bunch of single service scripts when Name Mangler does it better, more consistently, and with better error handling?
Quick and Dirty
The easiest way to build a file renaming workflow is to use the deceptively simple “Compose” functions in Name Mangler. Just quickly string together any of the large number of variables available in Name Mangler.
Here’s a quick example. I have a directory full of podcasts that are named in a couple of different formats. For example:
If I simply want to name them according to the date that the episode was uploaded, the “Compose” option is perfect. I use the Content Creation Date placeholder and choose the date format I like.
Drag in all of the episodes and preview what will happen.
That’s simple enough and it’s seriously fast. But that’s just the beginning of what Name Mangler can do.
Find and Replace
The “Find and Replace” function is also one of those Name Mangler features that looks basic on the surface but when you dig in a little starts to reveal a wealth of possibilities. The simple usage is what you probably think. Find some string and replace it with another. But when you check the Query is a regular expression the world opens up a bit. Here’s an example that removes some useless file sequence information based on a regular expression:
That’s a nice way to just clean up file names that contain everything I need but also some garbage.
Now I’m really getting somewhere. I’m renaming files in a way that makes some sense and it’s only taken a couple of minutes with Name Mangler. But now I’m going to turn it up to 11 and dive into the Advanced naming tools.
Let’s look at the file names again. They all start with a numeric code I don’t want. Then there’s an episode ID. Some also include a show title but others do not.
:::text 99593-040-helping-erik-procrastinate-productively-with-a-gtd-reboot.mp3 82309-generational-episode-026.mp3
By combining the Find and Replace action and the Advanced action, I can rename all of the files to one standard format.
The first action removes the numeric prefix. But that second action has a lot going on. Let’s take a look.
Name Mangler provides a custom scripting language with a builtin editor that’s surprisingly easy to use. Code completion and excellent documentation got me up and working in under 10 minutes.
The outer concatenate block combines the results of the inner block and the file’s extension.
The FindRegularExpression block is magical. It tells Name Mangler to look for the regular expression in the name that results from the previous action and replace it with the Regex match tokens. That’s right, Name Mangler returns the matching tokens and makes them accessible for creating file names. In this case, match $1 is the episode ID and match $3 is the name of the episode if it exists.
The final action in the series appends the date the episode was created.
Name Mangler provides a nice preview of the entire sequence.
So out of this mess, I get nicely named files like this:
:::text generational-episode-040-helping-erik-procrastinate-productively-with-a-gtd-reboot_2013-06-24.mp3 generational-episode-026_2013-08-25.mp3
Image Screenshots and Droplets
I like my screenshots to have a specific format for the file names. I don’t like dots in the file names and I don’t like leading or trailing spaces. This Name Mangler workflow fixes that.
I saved this workflow as a Droplet on my desktop and drag screenshot files onto the droplet to have them renamed in place.
Picture Library Problem
Here’s one final use case that is all too common. You’ve decided to export all of your photos from a managed system like iPhoto or Aperture and put them in some kind of folder structure. Don’t just put those old ugly file names into a nicely organized set of folders. Rename them with some intelligence.
This workflow takes the original file names in any format and prepends the original photo meta data modification date and a unique sequence number. The original file name is appended so that any useful information is still retained.
To get all of the 12,754 image files I exported from Aperture, I created a Smart Folder with a simple search criteria:1
So in just a couple of clicks I’ve created a reusable workflow for naming all of my photos.2
And if you’re not happy with the results, Name Mangler provides a convenient exit stategy that really works (even on 13,000 files):
I renamed almost 13,000 image files in-place on a NAS without a crash or hiccup. Name Mangler continues to impress me with it’s stability, ease of use and growing utility. It’s a great tool that should be in every nerd’s toolbox.
I love it when my favorite stuff sponsors my site. I hope you like it too. Many thanks to Many Tricks for sponsoring Macdrifter.