Change date of photo to match Exif

Notes published the
1 minute to read, 249 words
Categories: editing photo
Keywords: editing exiftool jpegoptim photo

I’m a big fan of jpegoptim, because without any loss in quality, it is able (granted, not always) to compress jpeg images file.

jpegoptim is also able to do a couple of other tasks, one of those is to preserve the timestamp of the files with the switch --preserve.

Note that JPEG images use the Exif format for storing metadata, and one common piece of metadata is the time when the photo was taken.

Nevertheless, in some contexts, it is useful if the Exif timestamp and the file timestamp match.

For example, most file managers are able to sort files by time, but not by the time embedded in the Exif metadata.

As one day I forgot to use the --preserve flag, I knew I would have been able to "reset" the original timestamp, and in fact, it turned out to be easier than I thought.

exiftool, as the name suggests, is able to read and write the embedded Exif format.

It is also able to change the file timestamp equal to the Exif timestamp of a single file

exiftool '-FileModifyDate<DateTimeOriginal' <file>

or all files inside a directory

exiftool '-FileModifyDate<DateTimeOriginal' <dir>

The man page contains a lot of other useful examples on how exiftool can come in handy for managing an image collection. It is definitely worth installing even for a one-shot operation, as it is like a swiss army knife for managing images, it might come in handy again.


Do you want to share your opinion? Or is there an error, some parts that are not clear enough?

You can contact me anytime.