Unix shell scripts for archiving digital photos in directories by date

by Jarno Elonen, 2003-06-17

I tried to archive my photos in directories by theme for a few years and eventually decided that doing it by date is the only sustainable way. Firstly, you will never be satisfied with the categories and secondly, you will later be tearing your hair off trying to remember the shooting dates of the photos after some image editor has stripped of their EXIF tags.

The fact that most digital cameras (like my Canon G1) store the shooting dates inside JPEG files in the EXIF format makes it possible to automatically archive the photos by date right after they are downloaded, which is exactly what the scripts below do. Here's an example of a directory tree they create:

1999
  1999-07
     1999-07-14
       IMG_48324.JPG
       IMG_48325.JPG
       IMG_48326.JPG
     1999-07-17
       IMG_48331.JPG
       IMG_48333.JPG
       IMG_48334.JPG
       IMG_48337.JPG
  ...etc...

move-digiphotos

This bash script (download it) scans EXIF tags from .JPG files in current directory with metacam, creates necessary directories under $BASEDIR and moves the files in them:


fetch-digiphotos

The fetch-digiphotos script (download) fetches pictures from a camera through gphoto2 into a temporary directory under $TMPDIR, moves them with move-digiphotos and finally offers to delete them from the camera:


Notes

These scripts were developed under Debian GNU/Linux but should work on other Unix-like operating systems as well.