How to set file last modified time in WinOS to the creation time in EXIF header?

Started by pstein, May 08, 2019, 10:33:22 AM

Previous topic - Next topic

pstein

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

Quote from: pstein on May 08, 2019, 10:33:22 AM
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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

pstein

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

Quote from: pstein on May 09, 2019, 01:13:22 AM
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.

QuoteHow 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

Quote2.) 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

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).