Adding date photo taken to filename

Digital photo organization is a pain.  Everybody has their own scheme (although I suspect many have none at all).  Here’s mine:

  1. Keep all pictures in one directory.  Yup, no subdirectories at all.
  2. When downloading files from camera’s SD card, batch rename (Win XP – select group of files, then ‘F2’ or right-click and ‘Rename’; Picasa also has a batch rename function) files according to the event/place/whatever.  You’ll end up with ‘Grandpa’s Birthday.jpg’, ‘Grandpa’s Birthday (1).jpg’, ‘Grandpa’s Birthday (2).jpg’, …
  3. Append the date the picture was taken to the front of the filename.  That way, the files will display in chronological order.

My Python script jpg_batch_rename.py (uses EXIF.py) does #3 for me.  For all files in a chosen directory, it extracts the date a picture was taken from the jpg exif datetime field.  If the file is not a jpg or if exif datetime info is not present for some reason, then it will extract the date the file was last modified.  The resulting date is appended to the front of each filename.  I don’t want to change the “file last modified” date itself, so at the end I reset it to what it was before the file rename.

Besides EXIF.py, the rest of the magic is done primarily with the Python os module.

For added usability, jpg_batch_rename can be used in conjunction with image_viewer2_SRO.py.  I adapted a script from the The Mouse vs The Python blog that uses wxPython to put the jpg_batch_rename functionality in a GUI.

After loading a directory with the button in the upper left, the first picture will be displayed.  (If there aren’t any pictures in the directory then it will crash, sorry.)  “Previous” and “Next” allow you to scroll through the photos – left over from the script I stol- er, borrowed.  The “Add Date to Filename” calls jpg_batch_rename and will append the file’s date to the front of all the files in the directory – even non picture files.  Checking the “Make backup” button will copy the original files to a “backup” subdirectory before making any changes.  The field at the bottom allows you to add an optional descriptor to add to the file name, as well as the date.

Before:

After:

Advertisements

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: