Archive for 2019 年 02 月

Fix up photo timestamps

7 二月, 2019

Went to a trip but forgot to adjust the time, or came back from a trip but forgot to set it back? (My new Lumix LX10 has the ability to set the length of the trip up front and avoids having to reset time after your trip, but my other camera is not there yet)

  • (optional) before you experiment with the script you may want to make a backup first
  • Find out by how many hours you want to shift the timestamps forward (+=) or backward (-=), then
    • exiftool -AllDates-=16:00 photo.jpg # shift back 16 hours
    • exiftool -AllDates="2016:12:17 12:00:00" photo.jpg # set to a specific timestamp
    • exiftool keeps the original file by renaming it with “_original" extension, keep them until you’re happy with the result
    • file size does change a bit but it does not touch the image portion of the file
  • To keep the original modified / created date on Mac, do
    • exiftool -CreateDate photo.jpg
    • This gives “Create Date : 2018:01:03 23:45:53″
    • touch -t 201801032345.53 photo.jpg
    • Combine the above two steps in an automated fashion:
    • for i in photo.jpg; do
      touch -t `exiftool -CreateDate $i | awk '
      BEGIN{FS=":"} {printf("%s%s%s%s.%s",$2,$3,$4,$5,$6)}
      ' | sed 's/ //g'` $i; done
    • Replace photo.jpg with *.jpg (or your raw file formats)—done!