I’ve decided to finally print my photo collection and put the prints in albums like in the good old days.

I spent a few days going through the files and picking what I want printed. I was not expecting to see that I will end up with 934 photos. But that’s not going to stop me, the albums I bought hold 500 photos each.

The problem is that the photos are sorted by directory, one directory per set. And I don’t have any idea what order the actual prints will be in when I get them back from the printer.

So to make sure I won’t spend another 8 hours sorting through 934 random-order photos I decided to rename them all so that the filename matches the file’s timestamp, and hope that the cameras’ times were anywhere near accurate.

To accomplish this task I had to write a crazy line of bash:

i=0 find -type f | while read F; do cp "$F" /home/andrew/temp/Print/by_date/`ls -ld "$F" --time-style="+%Y-%m-%d_%H:%M:%S" | cut -f 6 -d' '`_$i.jpg; i=$((i+1)) done

Took me a half an hour to write that but it works. The i++ was necessary because about 80 photos had the same timestamp, I don’t know why.

It turned filenames such as DSCF2345.JPG to 2007-05-02_12:04:34_351.jpg and just in case it put them all in one directory.

I’ll add something to this post later if it turns out that wasn’t sufficient :)

P.S. Turns out the service I used to print ignores filenames completely (it was some stupid Microsoft-based web app). It gave each photo a UUID and, annoyingly, sorted the thousand photos by UUID. Thanks, assholes :(