Skip to content

Instantly share code, notes, and snippets.

@bilalelreda
Last active March 1, 2020 03:49
Show Gist options
  • Save bilalelreda/1fa6b0eed6dd98ccabd7e07e4c933bfe to your computer and use it in GitHub Desktop.
Save bilalelreda/1fa6b0eed6dd98ccabd7e07e4c933bfe to your computer and use it in GitHub Desktop.
Fix EXIF dates and times with Jhead

Fix EXIF dates and times with Jhead

Installing Jhead on Mac OS X using Homebrew.

brew install jhead

Modifying the EXIF Date and Time

You adjust the date/time of the photos based on an offset. If, for example, your photo’s times are set 1 hour too far in to the future, we can subtract a single hour from all photos using the following.

jhead -ta-1:00 *.jpg

If the photos were set 12 hours, 20 minutes and 43 seconds too far in the past, we’d offset with a positive value.

jhead -ta+12:20:43 *.jpg

For offsets greater than 24 hours, we can use the -da option followed by two dates in yyyy:mm:dd format, or to include a time, as yyyy:mm:dd/hh:mm:ss. Because years and months have different numbers of days, rather than specifying an offset, we actually specify two dates for this option – the first being the date to translate to, relative to the second.

So if a particular photo was taken on the 29th February 2012 at 8:21am, but the camera recorded it as the 1st January 2000 at 2:24pm, we would use the following.

jhead -da2012:02:29/08:21-2000:01:01/14:24 *.jpg

It doesn’t matter that the photos weren’t all taken at the very same time specified by either date in this argument, Jhead will just work out the correct offset to use from the before and after dates and apply it correctly to each photo individually.

Setting the File System’s Timestamp

This is not strictly necessary but can be useful if you want your file system’s file creation dates to now match those of the newly fixed EXIF dates.

jhead -ft *.jpg

Credit: https://monkeyhybrid.com/2012/03/fix-exif-dates-and-times-with-jhead/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment