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.

    Of course, nowadays, I would ask this question on software recommendations - it got some great answers here, though

  • mattdm

    mattdm Correct answer

    9 years ago

    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.

    jhead

    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 Tools

    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.

    You are right, this is the opposite but infinitely more useful :)

    jhead is very useful for this - AND for many other jpg file manipulations. Be careful when using it - it is an extremely powerful tool that can wreak a certain amount of havoc if misused. I recommend using it in a batch file so you always do what you intend, and testing the result on a test file set first.

    +1 but I awarded myself the answer ;-) Just so others in future can find a way to do exactly what I asked ...

    @olibre Yes, that will work on Linux/Unix or Mac.

    I have noticed some picture browsers present (diaporama) pictures only on filename order (not on file modification time). Finally I use the EXIF timestamp to set the file time AND to prefix the file name. I use command `find -name '[0-9][0-9]*' -o -iname '*.jp*g' -type f -exec jhead -ft -n%Y%m%d_%H%M%S_%f {} +`. Explanations: `-name '[0-9][0-9]*'` to prevent renaming again files already having a date prefix (`'[0-9][0-9]` to take into account years and months). `-iname '*.jp*g'` can be skipped because `jhead` only processes supported files (only JPEG files). `%f` to keep original filename.

    Jhead did the perfect job! It's a fast and powerful tool.

    jhead does take care of recursive processing of content. 1) map network folder to a new drive letter (my content is stored on a NAS, skip if it's local) 2) open command line and type: `jhead -ft **\*.jpg` It's the double asterisk which will trigger the subfolder processing

    @user705734 That's not jhead — it's a feature of your shell. (Or whatever the Windows equivalent is.)

    @mattdm Not at all. This is not linked to the shell and is part of jhead's documentation. I just did this on a windows command line and this is NOT a syntax Windows supports. Just read the doc and you'll see for yourself.

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM