Set Date/Time Original from File Modification Date/Time

Started by jbarnes, July 25, 2018, 10:26:24 PM

Previous topic - Next topic

jbarnes

Firstly, apologies if this question HAS been asked before. Please link me to the discussion if that is the case.
However, I seem to only be able to find people wanting to do this the other way. I have a folder of photos taken from a ScoutGuard SG-562C trail camera that has failed to write Date/Time Original to the EXIF data, but has set the File Modification Date/Time as the correct date and time for the photos. I have tried using this code found here https://gist.github.com/rjames86/33b9af12548adf091a26

exiftool '-datetimeoriginal<filemodifydate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG")'

I have changed the quotation marks so that they are appropriate for my OS (Windows 10), and filetype to JPG rather than JPEG, and changing the tags to Date/Time Original and File Modification Date/Time as found in my EXIF and File data, but all I am getting are various errors such as "No file specified", "File not found" and, "The system cannot find the file specified".

Any tips as to what I might be doing wrong? What other info can I provide to help out with a solution?

Thanks in advance.

jbarnes

An update: I can manage to do one file at a time using e.g.

exiftool "-datetimeoriginal<filemodifydate" IMAG0001.JPG

but can't work out how to do all at once. I don't need all the other functions as I want to update the datetimeoriginal from filemodifydate on all photos in the folder. How can I process all at once so I don't hae to do all ~1800 one by one?

StarGeek

Just give the path to the directory instead of the single image name.  It can be either the full path (e.g. C:\path\to\photos ) or relative to the current directory.  Since your example is just the image name, I'm assuming that you have changed the directory to be in the same as the images.  In that case, you can just use a dot. 

So try this:
exiftool "-datetimeoriginal<filemodifydate" .

This command creates backup files.  Add -overwrite_original to suppress the creation of backup files.  Add -r to recurse into subdirectories. 
* 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).

jbarnes

Thanks for that. That seemed to work for me.

StarGeek

Do you have files other than jpgs?  Are they in subdirectories (re-read last line of my post)?

If all 1,800 are in the same directory and are all jpgs, then something is wrong if only 644 files updated.  There's some other detail missing.
* 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).

jbarnes

I think it was just an issue with the directory and probably too many things going on at once. Cleaned everything up and recopied the files to my working directory and it worked just fine on all photos second time around. Thanks again.