Author Topic: How to set file last modified time in WinOS to the creation time in EXIF header?  (Read 105 times)

pstein

  • Jr. Member
  • **
  • Posts: 17
Assume I modified a digital photo slightly.

Now I want to change the files last modified time (in Windows) back to the original time which can be retrieved from the EXIF header of the *.jpg.

How can I do this exactly?

I remember times when there was a menu in ExifTool GUI

Modify--->FileModifyDate as in ExifDateTimeOriginal

but it do not find it any more in newest ExifToolGUI software.

How does it work now?

Peter

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14405
    • ExifTool Home Page
Now I want to change the files last modified time (in Windows) back to the original time which can be retrieved from the EXIF header of the *.jpg.

From the command line, you do this:

exiftool "-filemodifydate<datetimeoriginal" FILESorDIRS

I can't help with the GUI though.  My only idea would be to try "-filemodifydate<datetimeoriginal" in the ExifTool direct box (if memory serves).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

pstein

  • Jr. Member
  • **
  • Posts: 17
Thank you.

Actually I prefer a GUI to not have to remember always the exact cmdline syntax.
But it is welcomed as a second solution.

But two more question:

1.) When I apply your command to a folder which contains some *.jpg files with NO EXIF header
then exiftools starts, processes e.g. 34 photo files and aborts.

How can I tell exiftool to skip (silently) *.jpg files with NO EXIF header and automatically continue with the following?


2.) How does your command work recursively for a whole dir tree?



Peter

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2365
1.) When I apply your command to a folder which contains some *.jpg files with NO EXIF header
then exiftools starts, processes e.g. 34 photo files and aborts.

Exiftool will still have to read those files to make the determination if there is data to be processed.  If there isn't a DateTimeOriginal tag in the file, nothing will actually happen with that file.

Quote
How can I tell exiftool to skip (silently) *.jpg files with NO EXIF header and automatically continue with the following?

You could use
exiftool -if "$DateTimeOriginal" "-filemodifydate<DateTimeOriginal" FILESorDIRS
This will skip any file that doesn't have the DateTimeOriginal tag.  But in the case of this command, files without that value will be skipped anyway, so it's a bit redundant. 

Though, I just realized that there might be other time tags in the file that are used to create the Composite:DateTimeOriginal (IPTC date and time tags), as well as the possibility of the XMP:DateTimeOriginal tag (though unlikely to exist if there isn't a DateTimeOriginal in the EXIF block).  To avoid writing in those cases, you can specify the group.
exiftool -if "$EXIF:DateTimeOriginal" "-filemodifydate<EXIF:DateTimeOriginal" FILESorDIRS

Quote
2.) How does your command work recursively for a whole dir tree?

Add the -r option to your command.  But take note that using a wildcard, such as *.jpg, will not work when you recurse.  If you need to limit to certain files, such as jpgs, then you need to use the -ext (extension) option, e.g. -ext jpg

Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.