Sorting images by EXIF date

Introduction

At least once a year we go for holiday together with some friends. No question, they all bring their digital cameras and take a load of pictures.

Right after we get back home they send me their images to upload them to our gallery.

The Problem

Then i usually end up with a directory structure looking smthg like:

First of all, there might be duplicate filenames as in the example above. But the major problem is that these photos are not sorted by the date they’d been taken which makes it hard to just browse them all and sort out the ones we dislike.

The Script

This is far from being perfect. Actually it’s just a quick hack, but it does the job for me.
It sorts all images given according to its EXIF CreateDate, copies/moves the files and prefixes them with an incrementing number.

Prerequisites:
  • Image::Exiftool

Tested on:
  • ArchLinux
  • Debian GNU/Linux Squeeze
Cameras tested with:
  • Nikon D70s
  • Nikon D80
  • Nikon Coolpix 5600
  • Apple Iphone 3GS

Example 1: Sort on Copy

Input Filenames: $ find a/ -xdev -iname "*.jpg*"

Copy and sort:
$ NameByExifDate.pl -c -d b/ find a/ -xdev -iname "*jpg*"

Resulting Filenames: $ find b/ -xdev -iname "*.jpg*"

Example 2: Sort on Move

Input Filenames: $ find a/ -xdev -iname "*.jpg*"

Move and sort:
$ NameByExifDate.pl -m find a/ -xdev -iname "*jpg*"

Resulting Filenames: $ find a/ -xdev -iname "*.jpg*"

The sort on move routine preserves the original directory structure while the sort on copy routine flattens the hierarchy to a single destination directory.

I highly appreciate feedback of any kind.


Comments

  1. exiv2 rename * is doing the same!!!

    • ohhh….damn. knowing this would have saved me 30min of work.
      thank you for the information, andi.

Leave a Reply

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