Simpler photo library management (filebydate)

Looking for a simpler way to manage your digital photo library?

A lot of people we know are burying themselves under a mountain of media files, loosing things.

And the software out there can really get you in trouble — tie you to one vendor or one platform, prevent you from organizing “your way”, hide information from you so you can’t back stuff up properly or use other programs to manage the library, etc.

A few years back I wondered if there wasn’t a simpler way. What I really wanted was to just use the filesystem directly, no fancy photo database or metadata. And then just use the nice, built-in Windows or Mac shell functionality to view the picture folders. But I wanted the files organized, and the date the photo was taken was the one thing that would never change — the primary way I wanted to look for pictures later. Unfortunately, I couldn’t trust the OS or the apps I was using to never touch that file date, and I needed it to be easily seen in all views.

So I wrote a simple little perl script to prepend the last modification date to the image files. “PIC_023812″ becomes “2005-12-04 180624 PIC_023812″ (you can, of course, then rename the PIC… part). We’ve been using it the last 5 years, a few friends have been using it, and that plain & simple solution has stood the test of time and been surprisingly useful.

So now, I’ve finally given it an upgrade to life as a Ruby gem, and gotten it out on a repository. The gem is called filebydate, and the renaming script which will get added to your path on installation is called renwdate.

I’ll post more later once the first release has propogated from rubyforge (once it has, installation will be as simple as ‘gem install filebydate’ for ruby users). Until then, please visit the rubyforge page.

Of course, turning it into a nice gem with complete docs, unit tests, etc. has made it a larger package. Here’s the original perl script, if that’s more to your liking.


Takes a wildcard as input, reads the date on each file, and
prepends that date into the file name (if the filename doesn't already
have a YYYY-MM-DD in it).  The purpose is to allow files (usually image
files) to be tagged with their creation date in the filename itself, so
that the creation date isn't lost when the file is further renamed (beyond
the date characters) or manipulated (such as rotating it or fixing red eye).
The filename is also used by many on-line photo printing services to print
the description of the picture, and this makes sure the date is part of
that string.

Bernie Thompson Jan 2001


use File::Basename;

@files= <$ARGV[0]>;

foreach $oldname (@files)
        if ($oldname =~ m/\d\d\d\d-\d\d-\d\d/) { next; }
	($readtime, $writetime) = (stat($oldname))[8,9];
        ($name, $dir, $ext) = fileparse($oldname,'\..*');
        ($sec, $min, $hour, $day, $month, $year, $junk) = (localtime($writetime));
        $year += 1900; $month += 1;
        $newname = sprintf("%s%04d-%02d-%02d %02d%02d%02d %s%s%s", $dir, $year, $month, $day, $hour, $min, $sec, $name, $ext);
        print "$newname\n";
	rename $oldname, $newname;
	utime($readtime, $writetime, $newname);

I’m hoping we can get a few more utilities created around this simple solution, to cover things like automatic renaming when picture files are imported, etc. And this Ruby gem could be a place to collect them.

Please let me know if you have any feedback or ideas for filebydate.

Comments (1) to “Simpler photo library management (filebydate)”

  1. [...] Simpler photo library management (filebydate) [...]

Post a Comment
(Never published)