Is it possible to use the current date and time in an argument? If I would like to find filed created in the last 24 hours, for example.
Yes (using the Extra "Now" tag (https://exiftool.org/TagNames/Extra.html)), but the trick is adjusting this by 24 hours before the comparison:
exiftool -filename -if "$createdate gt ${now;ShiftTime($_,-24)}" DIR
- Phil
I received a "bad substitution" error. Regarding the shiftTime... all I want to do is search. Will that actually shift it?
exiftool -filename -if "$createdate gt ${now;ShiftTime($_,-24)}" DIR >/Testing2.csv
"bash: $createdate gt ${now;ShiftTime($_,-24)}: bad substitution"
Sorry—it was a single quote issue. exiftool -filename -if -r '$createdate gt ${now;ShiftTime($_,-24)}' DIR >/DIR/Testing2.csv
Received File not found: $createdate gt ${now;ShiftTime($_,-24)}
Do I need the directory in front of the command in this instance?
The -if condition must come immediately after the -if option. The -r in your command is now being interpreted as the condition, so it must be moved elsewhere in the command line. Try this:
exiftool -createdate -r -csv -if '$createdate gt ${now;ShiftTime($_,-24)}' DIR >/DIR/Testing2.csv
Note that I am using the CreateDate tag here, which is the creation date from the EXIF metadata. I don't know if this is what you had in mind.
- Phil
I did notice that, and nothing meets the conditions, even when I change the hours to accommodate the time when the original was made. I adjusted the code to use the FileModifyDate, and again, nothing meets the conditions.
exiftool -FileModifyDate -r -csv -if '$FileModifyDate gt ${now(-24)}' DIR >DIR/Testing2.csv
I get: 11 directories scanned
8 files failed condition
0 image files read
I know one file meets the conditions, because its create date modify date is: 2016:08:15 13:17:41-05:00
Quote from: justmike on August 16, 2016, 12:34:02 PM
exiftool -FileModifyDate -r -csv -if '$FileModifyDate gt ${now(-24)}' DIR >DIR/Testing2.csv
You broke your
-if condition somehow -- the ShiftTime call is missing. See my first example.
- Phil
exiftool -filename -FileModifyDate -r -csv -if '$FileModifyDate gt ${now;ShiftTime($_,-24)}' DIR >DIR/Testing2.csv
Nothing... 11 directories scanned
8 files failed condition
0 image files read
What version of ExifTool are you using? This works for me with the current version.
- Phil
Version 10.25, now, and it worked... Thank you!
It works in the example you gave, but when I add other things to it, I get all the items listed, not just the ones modified in the previous 24 hours. In this case, it was over 60,000 images. Only 900 or so were changed, and I wanted to list those, not the others. Do I need to include an -if statement for each of the elements I am trying list? I guess the best way to say it is, I do not want a filepath, etc, if the modify date is not in the last 24... Is that somehow outside of the conditional statement?
exiftool -r -filepath -FileModifyDate -originaldocumentid -documentid -subject -csv -if'$FileModifyDate gt ${now;ShiftTime($_,-24)}' DIR >DIR/File.csv
You need a space after the -if option.
(watch those details!)
- Phil
:o Man I really thought it was going to be more complicated than that... I am running it now—takes about 50 minutes, usually, to go through all the files. I will update—thanks!
Fantastic—that got it. Thank you very much!!