Using "-if" to find certain files above/below a value

Started by Athlete, June 05, 2025, 08:03:12 AM

Previous topic - Next topic

Athlete

Guys

Very new to this.

I am trying to first use the tool to find PDF files equal to or above 150MB. I use the following command switchs

exiftool.exe -filesize -if "$filesize ge 150" "split_merged*.pdf"

Have I the correct syntax for tags with numerical values?

StarGeek

The problem is that you are using a string comparison (ge) which doesn't work the same way as a numeric comparison. Also, the FileSize tag lists the size as KB/MB/GB/etc. So a file that was "150 KB" would return as true.

What you need to do is a numeric comparison of the raw byte size. This is done using the hashtag # shortcut of the -n (--printConv) option. The -fast4 option is used to avoid decoding all the embedded metadata and only look at the file system metadata.
exiftool -fast4 -filesize -if "$filesize#>150000000" "split_merged*.pdf"

Having said that, exiftool will still be pretty slow compared to other options. If you are on Mac/Linux, then the find command will be significantly faster.

Windows, unfortunately, doesn't have an easy built-in solution. This SuperUser answer has a few ways to do it.

The best solution for Windows, IMO, is VoidTools Everything Search. Everything indexes all the files on your system using properties of the NTFS so it is insanely fast. Through the GUI, you would set the search as
c:\path\to\PDFs ext:pdf size:>150mb

There's also a command line tool you would install separately. And it uses the same syntax, so on the command line you would type
es c:\path\to\PDFs ext:pdf size:>150mb
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Athlete

Thank you for the prompt, clear answer and options. Plenty to explore.