21 Oct 2009

Batch renaming a group of photos

On Linux we can use jhead to batch rename a bunch of photos using many parameters, including EXIF information present on the files themselves.
Despite the fact that jhead is used to manipulate EXIF data it is as useful for renaming files.

First we need to install it:

sudo apt-get install jhead

Then we can choose from the many parameters which syntax best matches our needs.
In this short sample we'll just rename all the JPG files on a directory with a common prefix ( PIC_ ) and a sequential 4 digit number sorted by EXIF date if present or file date otherwise.

This can be achieved as follows:

jhead -nfPIC_%04i *.JPG

If we wanted to include EXIF date on the file name to get something like PIC_20091021-0164.jpg we could use:

jhead -nPIC_%y%m%d-%04i *.JPG

Of course there are many more options, check jhead's help for more info:

jhead -h

If needed you can also resize all those images at once using ImageMagick as explained on a previous post.

No comments: