Photo Corners

A   S C R A P B O O K   O F   S O L U T I O N S   F O R   T H E   P H O T O G R A P H E R

Enhancing the enjoyment of taking pictures with news that matters, features that entertain and images that delight. Published frequently.

Free Image Renaming Utility Available Share This on LinkedIn   Share This on Google   Tweet This   Forward This

12 February 2014

Martin J. Evans has released nefrename, a free renaming utility for Nikon image filenames, which can easily be edited to handle file-naming schemes from other manufacturers.

In a blog post, Evans tells the story:

The other day the filename counter (NNNN a 4 digit number) cycled so my my photo files are nolonger unique and this caused me some obvious problems. I tried renaming the files in a batch process in Capture NX but it only seems to work on NEF or JPG files and cannot rename them consistently if you have both. Plus I edit NEF files and rewrite as DSCNNNNcopy.JPG and it certainly cannot cope with that.

The solution was to rename my existing files as PREFIX_FILENO_DATE_(copy).(NEF|JPG).

Evans wrote the utility in Perl and used Phil Harvey's ExifTool to get the capture date used in the new filename from the image file's Exif header. It will run on both OS X and Windows systems with Perl and ExifTool installed.


The code reorders the found date as CCYY_MM_DD (year, month day as in 2014_02_12), which sorts properly. But it appends it to the existing filename. Since those numbered files are sequential, the sort order isn't affected but it you work with more than one camera (and therefore more than one prefix), it could be.

In the code itself, the filenaming substrings are distinct, so if you prefer to start with the date, which will preserve sort order regardless of prefix) you can simply move it to the front of the replacement string.

To look for files other than Nikon NEFs, add the suffix to (JPG|NEF) on line 52. You might also expand JPG to JPE?G to find any .JPEG files. We've seen them in the wild.

BackBack to Photo Corners