Change the date of a photo to match Exif

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

jpegoptim is also able to do a couple of other tasks, one of which 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.

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, can read and write the embedded Exif format.

It is also able to change the file timestamp and set it to the Exif timestamp:

exiftool '-FileModifyDate<DateTimeOriginal' /path/to/file

It can also do the same operation on all files inside a given directory

exiftool '-FileModifyDate<DateTimeOriginal' /path/to/directory

The man page contains a lot of other useful examples of how exiftool can come in handy for managing an image collection. It is 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.