ExifTool Forum

ExifTool => Newbies => Topic started by: justmike on August 16, 2016, 11:20:26 AM

Title: -if for date/time
Post by: justmike on August 16, 2016, 11:20:26 AM
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.
Title: Re: -if for date/time
Post by: Phil Harvey on August 16, 2016, 11:32:09 AM
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
Title: Re: -if for date/time
Post by: justmike on August 16, 2016, 11:44:40 AM
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
Title: Re: -if for date/time
Post by: justmike on August 16, 2016, 11:47:11 AM
"bash: $createdate gt ${now;ShiftTime($_,-24)}: bad substitution"
Title: Re: -if for date/time
Post by: justmike on August 16, 2016, 11:53:29 AM
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?
Title: Re: -if for date/time
Post by: Phil Harvey on August 16, 2016, 12:02:55 PM
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
Title: Re: -if for date/time
Post by: justmike on August 16, 2016, 12:34:02 PM
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
Title: Re: -if for date/time
Post by: Phil Harvey on August 16, 2016, 12:39:34 PM
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
Title: Re: -if for date/time
Post by: justmike on August 16, 2016, 02:44:28 PM
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
Title: Re: -if for date/time
Post by: Phil Harvey on August 16, 2016, 02:55:22 PM
What version of ExifTool are you using?  This works for me with the current version.

- Phil
Title: Re: -if for date/time
Post by: justmike on August 16, 2016, 04:33:20 PM
Version 10.25, now, and it worked... Thank you!
Title: Re: -if for date/time
Post by: justmike on August 17, 2016, 12:41:32 PM
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
Title: Re: -if for date/time
Post by: Phil Harvey on August 17, 2016, 12:42:37 PM
You need a space after the -if option.

(watch those details!)

- Phil
Title: Re: -if for date/time
Post by: justmike on August 17, 2016, 02:43:12 PM
 :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!
Title: Re: -if for date/time
Post by: justmike on August 17, 2016, 04:26:46 PM
Fantastic—that got it. Thank you very much!!