ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: ne17 on March 19, 2022, 05:16:36 PM

Title: -if condition FileModifyDate more than so many days ago
Post by: ne17 on March 19, 2022, 05:16:36 PM
Exiftool 12.40 on win10 command line

After a day's searching through the forum and many perl web pages (most of which suggest DateTime which isn't available in my command line) and a brief experiment with age.config which I couldn't get to work. I've bodged this into working


exiftool -d "%Y%j" -if5 "(${now; {my $myfmd=$self->GetValue('FileModifyDate');
                                                      $_=($_-$myfmd);
                                         }  } > 7)" -p "$filename $filemodifydate" -m -F -ext DNG -fast5 -r .


to print files modified more than a week ago - (I actually will use it with a complicated set of commands to avoid 'refreshing' my metadata on images I've recently 'refreshed' - hence the -if5 -fast5 to only use system tags)

Is there a simpler / more elegant way?
Title: Re: -if condition FileModifyDate more than so many days ago
Post by: Phil Harvey on March 19, 2022, 05:43:09 PM
Well done.

How about this to simplify things?

exiftool -d "%s" -if5 "$now - $filemodifydate > 7 * 24 * 3600" -p "$filename $filemodifydate#" ...

or if you want $filemodifydate formatted as you have done in the output:

exiftool -d "%s" -if5 "$now - $filemodifydate > 7 * 24 * 3600" -p "$filename ${filemodifydate#;DateFmt('%Y%j')}" ...

- Phil
Title: Re: -if condition FileModifyDate more than so many days ago
Post by: ne17 on March 19, 2022, 07:00:43 PM
Thanks Phil,

no the year and julian day conversion was just to find something that worked.

I'm very used to Excel's abundant date manipulation functions and couldn't believe it was so hard in Perl!

I'll swop to yours as that is simpler to read and understand when I look at it in years to come.

Nigel