I’ve been sorting through a number of digital photos this morning. Over the past few weeks, I’ve taken close to 500 photos over various days. Luckily, my Eye-Fi card automatically uploads them to a folder in my Dropbox so that’s not the tricky part. Since I updated the Eye-Fi card, the date stamp on the directories was reversed so my directories are no longer in sync with older directories. Keeping consistency in a file system is important when sorting through large amounts of files or directories.

Current directory: 1-2-2010
Required directory: 2010-2-1 (directory name reversed)

Logo

Name Mangler is my preferred method of batching renaming files. I don’t use it daily, but it’s like a Swiss Army Knife – you need it for certain situations. If you have it at the right moment, it can save a lot of time and energy.

I haven’t needed to dive into the advanced options in the past. I usually just use the basic options for replacing spaces in files or converting files to lowercase. Today was an exception since I needed to extract the day, month and year and reverse the order in which they appear. The advanced options allow you to use regex or regular expressions to apply a complex search and manipulate the results.

Update: The guys at Many Tricks sent me a better option to achieving this within 4 hours of my posting this:

Find: ^(\d+)-(\d+)-(\d+)$
Replace: $3-$2-$1

Here’s my code to achieve this (the hard way):

[concatenate
	[findRegularExpression
		"^[0-9]*-[0-9]*-(.*)?$"
		in <name>
		replace with "$1"
	],[findRegularExpression
		"^\d+-(.*)-\d+$"
		in <name>
		replace with "-$1"
	],[findRegularExpression
		"^(.*)-\d+-\d+$"
		in <name>
		replace with "-$1 "
	]
]

Here’s a breakdown of what’s going on:

  1. “concatenate” allows strings to be added together. Like taking the words “holy” and “smokes” and making them one expression: “holy smokes”
  2. findRegularExpression allows you to use regular expressions to find and replace text
  3. The crazy looking code is what is used to match what needs to be replaced. The important part is [0-9]*- matches any number between 0 and 9 up to a hyphen. (.*) allows that part of the expression to be stored in the variable $1.
  4. The rest should be self-explanatory.

I’m using the demo mode for all of this. It allows you to open and close it 25-times before you have to pay for it. The software costs only $10 and can be found on the Many Tricks website or at the Mac Store. I highly recommend it for anyone that needs to organize other people’s files (sent in by clients) or are closet librarians.

Name Mangler Screenshot

Screenshot of code in Name Mangler