ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: lei on March 22, 2024, 12:46:30 AM

Title: Search for files by date within file names
Post by: lei on March 22, 2024, 12:46:30 AM
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!
Title: Re: Search for files by date within file names
Post by: Phil Harvey on March 22, 2024, 09:36:13 AM
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
Title: Re: Search for files by date within file names
Post by: lei on March 22, 2024, 10:21:16 PM
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!