-if condition FileModifyDate more than so many days ago

Started by ne17, March 19, 2022, 05:16:36 PM

Previous topic - Next topic

ne17

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?

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

ne17

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