Conditional tags update based on comparison of tags from two files

Started by MaxxyM13, September 28, 2022, 02:09:11 PM

Previous topic - Next topic

MaxxyM13

I'm trying to tidy up my library of photos and movies migrated from Google Photos. Some pictures and movies have lost their original timestamps in the metadata but have them preserved in the json files. I'm trying to do something like

exiftool -d "%s" -v -tagsfromfile %f.%e.json "-FileCreateDate<PhotoTakenTimeTimestamp" "-CreateDate<PhotoTakenTimeTimestamp" "-DateTimeOriginal<PhotoTakenTimeTimestamp" -if '$FileCreateDate gt $PhotoTakenTimeTimestamp' filename.avi

and get "Condition: Use of uninitialized value $info{"PhotoTakenTimeTimestamp"} in string gt"

I understand that I get this error because "-if" may only test tags from the file being processed. So, I probably need to store PhotoTakenTimeTimestamp from the JSON file in a temp file or user variable and then use it to compare with FileCreateDate of the picture/movie file.

Question: Am I going the right way about it or am I overthinking and there's an easier way to do it? I've spent quite some time searching around but couldn't find a use case for using tags from one file to compare with tags from another. What's the best way to do it?
 

StarGeek

For image files, I would have suggested copying the "PhotoTakenTimeTimestamp" into the file in a rarely used tag such as AttributionName, then running the compare, then removing the AttributionName.  But your example shows an AVI file, so this would not work.

The only other thing I can think of would be to copy the "PhotoTakenTimeTimestamp" from the json into the FileModifyDate of the file, and then compare the FileModifyDate to the FileCreateDate.  Or if you're on a Mac, maybe the MDItemFSCreationDate.
"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

MaxxyM13

Quote from: StarGeek on September 29, 2022, 10:34:06 AMFor image files, I would have suggested copying the "PhotoTakenTimeTimestamp" into the file in a rarely used tag such as AttributionName, then running the compare, then removing the AttributionName.  But your example shows an AVI file, so this would not work.

The only other thing I can think of would be to copy the "PhotoTakenTimeTimestamp" from the json into the FileModifyDate of the file, and then compare the FileModifyDate to the FileCreateDate.  Or if you're on a Mac, maybe the MDItemFSCreationDate.
Great idea, thank you!