Smart rename for photo image files (jhead)

 

If you have digital camera then you also have lots of digital photos on your disk drive. For you who want to better organise your photos here is one quick tip.
 

Cameras name photo files in non human friendly ways, for example last few photos I took have these filenames:

$ ls pa198126.jpg pa198130.jpg pa198134.jpg pa198138.jpg pa198142.jpg pa198146.jpg pa198150.jpg pa198127.jpg pa198131.jpg pa198135.jpg pa198139.jpg pa198143.jpg pa198147.jpg pa198151.jpg pa198128.jpg pa198132.jpg pa198136.jpg pa198140.jpg pa198144.jpg pa198148.jpg pa198129.jpg pa198133.jpg pa198137.jpg pa198141.jpg pa198145.jpg

 Just from looking at the file names and not oppening these photos you can't really get much information. If you wish to smartly bulk rename your photo files so that the file names have more meaning continue reading.  

First we need to install jhead. If you are using Fedora use yum for installing jhead and for Debian (Ubuntu) based systems use apt-get:
 

yum install jhead
or
apt-get install jhead

 

To give these images a new name we will use date written by the camera to their exif tags. Exif tags contain a lot of useful information like date and time the shoots were taken, brand and model of the camera, shutter speed and other info.
 

We will use only the time info for now, but you can play with all the settings as you wish.
 

To rename the images with date and time when they were shoot we can use jhead with these parameters:
 

jhead -n%Y%m%d_%H%M%S p*.jpg
 

After that we have a much more human friendly image names:
 

$ ls
2008_10_19_161728a.jpg 20081019162047.jpg 20081019172113.jpg 20081019173315.jpg 20081019161728.jpg 20081019162100.jpg 20081019172124.jpg 20081019173330.jpg 20081019161830.jpg 20081019162204.jpg 20081019172137.jpg 20081019173349.jpg 20081019161840.jpg 20081019162218.jpg 20081019172141.jpg 20081019173806.jpg 20081019161949.jpg 20081019171956.jpg 20081019172231.jpg 20081019173816.jpg 20081019162000.jpg 20081019172009.jpg 20081019173256.jpg 20081019_162034.jpg

 If you have some more examples how this approach can be enhanced even more please post it in the comments.   UPDATE:
  I read a great article on linux.com about automated image processing. Highly recommended.