[GRLUG] Set .jpg modified date/time from EXIF info?

Raymond McLaughlin driveray at ameritech.net
Wed Jun 20 03:15:36 EDT 2007


If you don't have a copy of jhead laying around the following bash
script might work for you. You need to substitute the correct year for
'2003' in this example. (In case word wrap mangling the do loop is 2 lines.)

  for i in $(ls *.jpg)
  do
    mdate=$(strings $i| grep 2003:| cut -d ':' -f 1,2,3,4| uniq| sed
s/://g|sed s/' '//)
    touch -t $mdate $i
  done

I hope this helps
Raymond McLaughlin

Benjamin Eavey wrote:
> Hello!
> 
> I have a pet project I'm working on, and I figure there HAS to be an 
> easier way to do this.  I'm trying to get a large collection of .jpg 
> files to show their last modified date/time to be the same as the photo 
> creation date/time stored in the EXIF information in the file, which was 
> put there by the digital camera that took the pictures.
> 
> Failing that, I'll just manually set the dates of the files so it's 
> close to when the photos were taken, but I'd rather have it be as exact 
> a match as possible.  Anybody know of a way to do this?
> 
> Going to sleep now...  trying to remain intelligible...  :)
> 
> Thanks,
> 
> -Ben


More information about the grlug mailing list