Find files where filemodifydate more than 1 day off from datetimeoriginal

Started by kd74g8d, May 16, 2021, 01:20:25 PM

Previous topic - Next topic

kd74g8d

I just discovered ExifTool and I love how powerful it is. It looks to have an active community involved with it which is also great and probably why it's so popular.

Anyway, I have a question. I'm trying to use the Shift Date/Time module on variables in a conditional search and wondering if that is possible. Basically, I want to find all JPEGs where the datetimeoriginal is more than a few hours apart from filemodifydate. But I can't seem to get it to work. I've been googling and trying different commands for over a day so thought I'd reach out. Some commands I've tried so far:


exiftool -alldates -filemodifydate -r -if '(($datetimeoriginal lt $createdate) or ($datetimeoriginal lt "$filemodifydate+=1:0:0 0") or ($filemodifydate lt "$datetimeoriginal+=1:0:0 0")) and ($filetype eq "JPEG")' /share/pictures/
exiftool -alldates -filemodifydate -r -if '(($datetimeoriginal lt $createdate) or ($datetimeoriginal lt "$filemodifydate+=5:0:0 0") or ($filemodifydate lt "$datetimeoriginal+=5:0:0 0")) and ($filetype eq "JPEG")' /share/pictures/
exiftool -alldates -filemodifydate -r -if '(($datetimeoriginal lt $createdate) or ($datetimeoriginal lt "${filemodifydate}+=5:0:0 0") or ($filemodifydate lt "${datetimeoriginal}+=5:0:0 0")) and ($filetype eq "JPEG")' /share/pictures/
exiftool -alldates -filemodifydate -r -if '(($datetimeoriginal lt $createdate) or ($datetimeoriginal lt "${filemodifydate}+=::5 ::") or ($filemodifydate lt "${datetimeoriginal}+=::5 ::")) and ($filetype eq "JPEG")' /share/pictures/
exiftool -alldates -filemodifydate -r -if "(($datetimeoriginal lt $createdate) or ($datetimeoriginal lt \"${filemodifydate}+=::5 ::\") or ($filemodifydate lt \"${datetimeoriginal}+=::5 ::\")) and ($filetype eq \"JPEG\")" /share/pictures/


But the results always seem to show files that I don't want it to. Does someone know if this is possible and, if so, how to do it?


======== /share/pictures/IMG_1234.JPG
Date/Time Original              : 2006:07:16 00:05:55
Create Date                     : 2006:07:16 00:05:55
Modify Date                     : 2006:07:16 00:05:55
File Modification Date/Time     : 2006:07:16 00:05:55-06:00


I'm using perl-Image-ExifTool-12.16-3.el7.noarch (dated 2021-01-21) on Linux (Centos 7.9.2009) on perl v5.16.3. Thank you in advance for anyone's time!

StarGeek

When you do this
$datetimeoriginal lt "$filemodifydate+=1:0:0 0"
you are comparing the value of the DateTimeOriginal tag to the string "$filemodifydate+=1:0:0 0", not the FileModifyDate tag.  I think you were confusing shifting a time in a comparison with the ability to shift a tag's date/time while writing that tag, which is what -filemodifydate+='1:0:0 0' would do, which is to add 1 year to the FileModifyDate tag value and write the new value.

What you'll want to use is the ShiftTime helper function
-if '$datetimeoriginal lt ${filemodifydate;ShiftTime("+1:0:0 0")}'
This will compare the value of the DateTimeOriginal to the value of the FileModifyDate + 1 year.

The ShiftTime helper function name is case sensitive.

Further reading: ExifTool Date/Time Shift Module
"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

kd74g8d

Thanks for clarifying that, StarGeek. I'm now able to do what I need to so I appreciate the tip!

Cory