Sunday, 28 January 2018

metadata - Is there a free program to (batch) change photo file's date to match EXIF?



I want to specify a directory and have the software find all the photos in the directory and its sub-directories, and if they contain EXIF date/time, it sets their filesystem timestamp to match the EXIF.



Answer



This is the inverse of Is there any software which will set the EXIF Dates based on the file's modification date?, and I'm sure all of the programs listed there will apply.



Of these, for this very simple task, jhead is my suggestion. For example, the command


jhead -ft *.jpg

sets a bunch of files so that the file timestamp matches EXIF.


jhead with find, for going through subdirectories


In order to perform recursion into subdirectories, you could to combine it with the find command available on Linux/Unix/Mac (or Cygwin for Windows):



find . -name '*.jpg' -exec jhead -ft {} +

Or to find any of *.JPG *.JPEG *.jpg *.jpeg ... you can also try


find . -iname '*.jp*g' -exec jhead -ft {} +

You can also use find to just show all the files that would be... found, without executing any other command (like jhead):


find . -iname '*.jp*g'


Other utilities like ExifTool or Exiv2 are much more capable, but at the price of complexity. I can never remember offhand the right options to do anything with those and have to look at the documentation every time, but jhead -ft is easy to remember with the mnemonic "fix time".



ExifTool


Just for completeness, though, I did look at the documentation, and with ExifTool, do this:


exiftool -r '-DateTimeOriginal>FileModifyDate' directoryname

(Remove the -r if you don't want recursion, and if you do that, you can also give a list of files or a wildcard instead of directoryname.) And be careful with those quotes — if you're running this on Windows, you want " instead of '.


Exiv2


With Exiv2:


exiv2 -T rename *.jpg

Beware that with lowercase -t (or without any -T) Exiv2 will also rename the file to a new name based on the timestamp, which may be very confusing. Exiv2 also does not do recursion.



No comments:

Post a Comment

Why is the front element of a telephoto lens larger than a wide angle lens?

A wide angle lens has a wide angle of view, therefore it would make sense that the front of the lens would also be wide. A telephoto lens ha...