Search for files by date within file names

Started by lei, March 22, 2024, 12:46:30 AM

Previous topic - Next topic

lei

Dear Forum Experts,

I have a collection of scanned PDF files, each with filenames starting with a date in the format year-month-day, followed by descriptive words. For instance: "2021-08-15 Officeworks.pdf". I'm seeking a method to search for files based on these dates. For example, I want to list all files preceding January 29, 2024. Can this be achieved using exiftool?, if yes, could you assist me in achieving this?

Thanks in advance!

Phil Harvey

Something like this should do it:

exiftool -filename -if "$filename lt '2024-01-19'" -fast5 DIR

The -fast5 isn't necessary, but it will speed things up a lot because you don't need to read any metadata from the file.

There are various options that will allow you to format the output however you want.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

lei

Oh, I see. So you can compare strings like that directly. I was under the impression that I needed to convert the date strings in the filenames into date objects first. Also, thanks for letting me know about the -fast5 option. I guess I was just being lazy and didn't bother to read the manual properly. Thanks a lot!