I often face the problem of sorting through thousands of pictures and wanting to create some sensible hierarchy before importing them into another
program or burning them to a DVD. This tip will move pictures into a year/month directory hierarchy naming each file based on the day and time it was taken. This usually corresponds well to subject or location. THIS HINT WILL MOVE AND RENAME YOUR FILES. DO NOT RUN IT ON YOUR ONLY COPY!
Read the rest of the hint for the how-to...
[robg adds: Heed the warnings; do not do this to your only copy of a given set of images! Personally, I just let iPhoto manage everything, but then again, I don't take and manage images for a living...]
First make a hierarchy of directories:
% mkdir your_output_directory
% cd your_output_directory
% for y in 2000 2001 2002 2003 2004 ; do
> mkdir $y ; cd $y ;
> mkdir 01_Jannuary 02_February 03_March 04_April ;
> mkdir 05_May 06_June 07_July 08_August ;
> mkdir 09_September 10_October 11_November 12_December ;
> cd .. ;
> done
[Type what's shown on each line, but without the leading % or >]
jhead -n'/full/path/to/your_output_directory/%Y/%m_%B/%d-%T' source_dir/*
Since you did read the fine manual, you know all about -exonly and -model, as well as the difference between the -n and -nf options. I, myself, always do a -ft as well. If you read the copy on the web, you noticed that jhead's recursive feature is only supported on Windows, so I offer the following workaround:
find source_dir -type f -name '*.jpg' \
-exec jhead -n'/full/path/to/your_output_directory/%Y/%m_%B/%d-%T' {} ;
When you're done, you'll have your photos in a nice hierarchy something like this:
./2001/05_May/12-09:44:57.jpg
./2003/05_May/03-14:41:19.jpg
./2003/06_June/13-11:16:00.jpg
./2003/06_June/13-11:16:06.jpg
./2003/06_June/28-15:56:19.jpg
The filenames may initially be hard to read, but they make sense. In the above example, for 2003 we have one photo from May 3 and then two photos from the 13th of June -- the first one taken at 11:16:00 (h:m:s) and the other taken six seconds later. Then finally one on the 28th of June. The leading digits on the month names has the nice benefit that you can get a text listing in chronological order with:
find . -type f -print | sort
You can also get a histogram by hour:
find . -type f -print | cut -d- -f2 | cut -d: -f1 | sort | uniq -c | sort +0nr
Or by year/month:
find . -type f -print | cut -d/ -f1-3 | sort | uniq -c | sort +0nr
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040324071531479