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!
Try this. You need at least ver 12.22 in order to use Basename or have taken it from the example.config file (https://raw.githubusercontent.com/exiftool/exiftool/master/config_files/example.config).
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 (https://exiftool.org//exiftool_pod.html#Helper-functions) formats the DateTimeOriginal to be the same as the BaseName of the file and then compares the two.
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.
To see everything that exiftool is doing, you could add the -v (-verbose) option (https://exiftool.org/exiftool_pod.html#v-NUM--verbose) and redirect the output to a txt file. Using -v2 or -v3 will give you a lot of details.
Thank you very much!!