Check for DateTimeOriginal warning and apply FileModifyDate

Started by cyian22002211, February 03, 2022, 07:44:22 AM

Previous topic - Next topic

cyian22002211

Hi,

Firstly thanks for this awesome tool :)

So, for some reason I've got a bunch of files which were created with an invalid date.

The warning is:
`Warning: Month '00' out of range 1..12 in ExifIFD:DateTimeOriginal (PrintConvInv) - IMG_5342.jpeg`

Basically, I would like to check for those files that:

IF `EXIF:DateTimeOriginal` then it should re-write the `DateTimeOriginal` with the `FileModifyDate`.

I tried this:

`exiftool '-FileModifyDate<EXIF:DateTimeOriginal' -if "$warning" DIR`

But it tells me:
`1 files failed condition`

How can I correctly write the new DateTimeOriginal IF a warning appears? Thanks

Phil Harvey

You can check for a month of "00" like this:

exiftool -if "$exif:datetimeoriginal =~ /^....:00/" "-datetimeoriginal<filemodifydate" DIR

- 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 ($).

cyian22002211

Thanks Phil, but that example still tells me:
`1 files failed condition`


Thanks, it worked (single quotes, I'm on a Mac)

Is there a way it can check for just the warning? As I dont know it will always be '00'

Also, can it maintain the DateModified/Created from the original?

Phil Harvey

There is no easy way to just check for the warning.  Plus, there are many other different warnings which may occur.

Add -P to preserve the original modification date.  And to also preserve the original creation date on Mac, copy back FileCreateDate, like this:

exiftool -if '$exif:datetimeoriginal =~ /^....:00/' '-datetimeoriginal<filemodifydate' -P -filecreatedate DIR

But this requires that you have the "setfile" utility installed.  If you don't, you can install it by with this command:

xcode-select --install

See FileCreateDate in the Extra Tags documentation for the documentation on this.

- 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 ($).