ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: cyian22002211 on February 03, 2022, 07:44:22 AM

Title: Check for DateTimeOriginal warning and apply FileModifyDate
Post by: cyian22002211 on February 03, 2022, 07:44:22 AM
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
Title: Re: Check for DateTimeOriginal warning and apply FileModifyDate
Post by: Phil Harvey on February 03, 2022, 07:49:45 AM
You can check for a month of "00" like this:

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

- Phil
Title: Re: Check for DateTimeOriginal warning and apply FileModifyDate
Post by: cyian22002211 on February 03, 2022, 07:55:32 AM
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?
Title: Re: Check for DateTimeOriginal warning and apply FileModifyDate
Post by: Phil Harvey on February 03, 2022, 08:05:18 AM
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 (http://exiftool.org/TagNames/Extra.html) for the documentation on this.

- Phil