Preserve photo timestamp when exporting from iPhoto

Jul 30, '09 07:30:03AM

Contributed by: c8h10n4o2

When photos are exported from iPhoto using the Export function, all the photos will get the current date/time stamp. But if you use any of these photos in an app that organizes them by date/time, then the organization will be lost. For example, I export a set of images from iPhoto to view in my Wii's photo tool, but those images are organized by date.

To fix this problem, I took advantage of the EXIF data in the JPEG images from my digital camera. To batch change a large set of images, I use the open source command-line tool jhead, which is available as a pre-compiled Intel binary (source code is also available from the website, or via Fink).

I copied the jhead binary into an Applications folder in my home directory, and made it executable with the following command:

chmod 750 jhead
Then I wrote a simple shell script to batch update the images:
#!/bin/bash

for i in *.JPG; do base=`basename "$i" .JPG`; mv "$i" "$base".jpg;done
find . -type f -name "*.jpg" -exec ~/Applications/jhead -ft {} \;
Don't forget to make the shell script executable as well.To run the script, just change into the directory with all images and run the shell script.

[robg adds: This worked for me, though the script does more than just change the date -- it also changes the extension from .JPG to .jpg. In my case, my exports already had a lower-case name, and I didn't want the filename changed, so I simplified the script by just using the second (find . -type...) line.

Once I had it down to one line, I realized a script wasn't necessary. Instead, I created a new alias in my .profile file:
alias fixdate="find . -type f -name \"*.jpg\" -exec ~/bin/jhead -ft {} \;"
Now after an export, I just cd to the directory and type fixdate to correct the date on the exported images.]

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20090728095658110