I use 2 digital cameras, and my phone, to take pictures nearly every day. I came accross a perl script written by Lars Strand. This copied photos from CAM0001.JPG to a date formatted file such as 20070113.0900.JPG.

I decided to take this as a base, and change it into something that suited my own needs.

The script will take directories on the command-line and copy any pictures found to a target directory set within the script. It then creates a file and directory structure based on the EXIF time/date found in the JPEG.

For example,

  • /source/CAM0001.JPG

now becomes

  • /target/2007/11.nov/20070113.0900.jpg

.. making the files easy to find and splitting them into months.

The script produces an output such as,

ExifSort v1.0 - http://www.nooblet.org/exifsort/

 o Processing folder, /mnt/storage/Photos/100DSCIM/
 o Processing folder, /mnt/storage/Photos/100CASIO/
    CIMG0553.JPG -> 20071111_145714.jpg
    CIMG0554.JPG -> 20071111_153500.jpg
    CIMG0555.JPG -> 20071111_153529.jpg
    CIMG0556.JPG -> 20071111_153614.jpg
    CIMG0557.JPG -> 20071111_155707.jpg
    CIMG0564.JPG -> 20071111_181839.jpg
    CIMG0567.JPG -> 20071111_182038.jpg
    CIMG0569.JPG -> 20071111_182659.jpg
    CIMG0574.JPG -> 20071111_215006.jpg
    CIMG0575.JPG -> 20071112_120508.jpg
    CIMG0580.JPG -> 20071112_120723.jpg
    CIMG0582.JPG -> 20071112_182803.jpg
 o Processing complete.
    12 files copied.
     - 101 files the same.

The script checks modified dates and file sizes, and will compare the md5 checksum if it still isn’t sure, to know if it has already copied an existing file.

The photos folder in my family photo gallery is a direct result of this exif sorting script.

Requirements:

Download

  exifsort.pl (5.2 KiB, 1,077 hits)

10 Responses to “exifsort.pl – Sort digital images by EXIF date.”

  1. It seems jbwan found this script useful and said so in his blog. Thanks for the comments, they’re appreciated :)

    March 8th, 2008 | 11:36am
  2. You’re welcome. I’m still using the script and I have yet to find any problems with it. Many thanks for the great piece of software!

    June 8th, 2008 | 6:56pm
  3. mafi29

    Very useful. This is exactly what I was looking for. Thank you very much!

    September 1st, 2008 | 12:56pm
  4. len

    Thank you very much for this script, it is very useful for me for sorting trip photos from different people.

    November 2nd, 2008 | 11:36am
  5. Johan Widell

    Perfect, I’ve had a pile of photos unsorted for a while, since I switched from XP to Linux. This perl script just saved my day! Thanks.

    April 12th, 2009 | 7:12pm
  6. Jonas W.

    Absolutely brilliant! I’ve been looking for a way to do this for years! The only thing I miss would be a way to make it recursive so you could point it at a full drive with multiple sub folders, but hey – I can live with it :-)

    October 14th, 2009 | 1:49pm
  7. Thankyou for the kind comment.

    To help you in your task of sorting an entire drive. If you mounted a USB flash drive to /mnt/usb, you could use ‘find’ to make exifsort recurse the directory tree.

    find /mnt/usb -type d -exec ./exifsort.pl {} \;

    October 14th, 2009 | 3:59pm
  8. joepres

    Can you help on how to open the script? I mean how to start it and begin performing all the arrangements?

    Thanks in advance

    June 3rd, 2010 | 5:23pm
  9. @joepres, first edit the script in your favourite text editor, example nano:

    $ nano exifsort.pl

    Find the line with ‘$targetpath’ and set this to where you want to output your sorted images. Save the file (in nano that is ctrl+x) and run with

    $ ./exifsort.pl /path/to/my/images /path/to/more/images

    July 14th, 2010 | 12:05pm
  10. July 12th, 2008 | 8:41pm

Leave a Reply