[SOLVED] Struggle how to get an IF statement integrated

Started by minime, November 23, 2021, 04:40:47 PM

Previous topic - Next topic

minime

Hi all,

I am almost there, but I struggle with my "IF" part. So far I have this:

exiftool -r "-datetimeoriginal<filename" -P -overwrite_original C:/Images/

but I would like to only let it run IF:

1) datetimeoriginal is null
2) datetimeoriginal =! filename (without extension, in the format of "20071006_153426.jpg")

Should be simple, but would appreciate if someone could enlighten me on this one.

Many thanks!

StarGeek

Try this.  You need at least ver 12.22 in order to use Basename or have taken it from the example.config file.
exiftool -P -overwrite_original -if "not $DateTimeOriginal or ${DateTimeOriginal;DateFmt('%Y%m%d_%H%M%S')} ne $BaseName" "-datetimeoriginal<filename" /path/to/files/

The DateFmt helper function formats the DateTimeOriginal to be the same as the BaseName of the file and then compares the two.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

minime

Thank you kindly, that worked!

Is there a way to write what it did to a text file? I would have expected an update to 15 files, but it updated 17 and I would like to investigate what it really did.

StarGeek

To see everything that exiftool is doing, you could add the -v (-verbose) option and redirect the output to a txt file.  Using -v2 or -v3 will give you a lot of details.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype