Renaming the image files in my photo workflow

No matter how you manage your photos, they will always be files on a computer. As long as we’ll have to deal with files, we must ensure that each name refers undoubtedly to one expected image. The default file name set by the camera does not meet those expectations, so we have to rename our files. It’s up to every photographer to choose one or several patterns, and to stay consistent. I chose to name my photos using the date.

Most of the photo management softwares can rename your photos as you import them. But the flexibility on the name pattern may differ a lot. For this question of flexibility, I choose to rely on a dedicated software, exiv2.

Why image files should be renamed ?

A recurring problem for every photographer is how to correctly name, so identify, its photo files. Why change the default file name (especially if we have a good classifying method) ? I see two reasons:

  • Name limit: with a Canon camera, files names each name follows with the pattern IMG_XXXX.JPG where XXXX may be between 0001 to 9999 (0000 is never set). What happens when you just shot a picture which file name is IMG_9999 and you shoot the next one ? The counter is reset and the name of the new file is IMG_0001. Since your file system orders your files by their names, on your computer, photos named IMG_0001 and following will be found before the one shot prior to them in your file manager. You will also have redundant names in your collection. Even if you store your photos in distinct collections so it is unlikely to have the same name in one folder, you may find yourself in a situation when this may occur.
  • Different devices usage: If a folder contains photos shot with different cameras, the files will be ordered in a really random way because you’ll have no control of the naming. You will also risk names redundancy (so you’ll must rename those files).

Using the timestamps

A photo is taken at a given time. So even if the name will not be much informative, I have chosen my name pattern to be based on the timestamp. That information is available in the file, set by the camera in the EXIF metadata. The only constraint is that the clock of the camera was correctly set (and even if it was not, it is possible to correct it).

Using the timestamp with exiv2

Exiv2 is available on Linux, Windows and OsX. It is a library anyone can use in its software, but it is also directly usable in the command line, which means that the software does not come with a nice user interface in which you just click a Do the job button. But that also mean that you can include it into a nice and fancy workflow. The basic usage of exiv2 will require to launch the terminal window and type the right command, but this also allow to never care about clicking a button. In this post, I’ll only explain the basic command.

Basic usage

The basic purpose of exiv2 is to display the EXIF metadata. Just type the following command:

exiv2 IMG_2143.CR2

This will result in the following output on the terminal.

File name : IMG_2143.CR2
File size : 10556702 Bytes
MIME type : image/x-canon-cr2
Image size : 3648 x 2736
Camera make : Canon
Camera model : Canon PowerShot G11
Image timestamp : 2013:04:01 15:35:26
Image number : 135-2143
Exposure time : 1/800 s
Aperture : F4
Exposure bias : -1/3 EV
Flash : No, compulsory
Flash bias : 0 EV
Focal length : 15.7 mm
Subject distance: 44
ISO speed : 100
Exposure mode : Program (P)
Metering mode : Multi-segment
Macro mode : Off
Image quality : RAW
Exif Resolution : 1600 x 1200
White balance : Auto
Thumbnail : image/jpeg, 4070 Bytes
Copyright : 
Exif comment :

Ok, I can already see the geeks starting writing a script with grep and awk to fetch the date value… Well stop ! Exiv2 can rename your files based on the date information. Simply type:

exiv2 rename IMG_2143.CR2

This will rename the file IMG_2143.CR2 to 20130401_153526.CR2. By default, exiv2 already rename your image based on the date metadata. Of course, you can use wildcards to process files in a batch. Using the following will rename all the CR2 files in the folder:

exiv2 rename *.CR2

The basic usage is easy, but there are two problems:

  • This is not exactly the name pattern I want to use.
  • If I have two images taken at the same second (think about bracketing or burst shots), exiv2 will try to set the same name and will not know what to do (and will ask you).

Fortunately, exiv2 can manage both of those situations.

Dealing with identical names

It is very simple and exiv2 can handle such a situation: just add the -F option wich will add _1, _2… to the name pattern. Without this option, if the name already exists, exiv2 will ask for what to do. So to deal with photos taken at the same time, you just have to execute:

 exiv2 -F rename *.CR2

Defining the filename pattern.

This is just as easy, we just have to provide the right pattern in the command. If you have programing knowledge, exiv2 use the library strftime.

My pattern is close to the default one, except that I want the year on two digits and the dash a separator instead of the underscore. So I use:

exiv2 -r'%y%m%d-%H%M%S' -F rename *

The file name then becomes 130401-153526.CR2.

This pattern is flexible enough to add other informations. Some photographers like to add the event name, so if you want to prefix the name with an event name as Japan_ for a trip to Japan, use the following:

exiv2 -r'Japan_%y%m%d-%H%M%S' -F rename *

Applied to my file, the name would become Japan_130401-153526.CR2.


Exiv2 is finally a simple software, even if it requires to open a terminal window and type commands. But I do not type any command as command line tools can be automated, that is something I’ll explain in a later posts. Exiv2 is usable for jpg and RAW format. The only prerequisite is to have your digital camera clock set correctly.

This is how I chose to rename my photos, what is your way ?

About Darko Stankovski

I started to take photos with my father's Canon AE-1 as a kid and never rally stopped. I love to explore new techniques and will use this blog to post some tips. I can't really qualify myself as I enjoy landscapes, portraits, stages and toy photography. If you want to stay in touch, you can follow me trough those link.

Loading Facebook Comments ...

One thought on “Renaming the image files in my photo workflow

  1. Pingback: Simplifying your Workflow with Automator | Darko Stankovski Photography

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.