Find Files by Size

Find all TIFFs in a directory smaller than 90 MB:

$ find /dir/to/search -name *.tif -size -90M -exec ls -lh {} \;

Get just the size and path and write to a file:

$ find /dir/to/search -name *.tif -size -90M -exec ls -lh {} \; | awk '{print $5 , $8}' > output.txt

Useful for finding images that might have been scanned at the wrong resolution/bit depth/etc.

2 thoughts on “Find Files by Size”

  1. the gnu version of find also has printf which can be handy in some cases. I don’t think it has a nice way to print out human readable sizes.

    A common find gotcha…files with spaces in them can be funky if you’re passing it onto xargs. So in that case use -print0 or -printf0 in the find side and -0 in xargs.

    In this case you’d do something like


  2. I can’t remember what I meant by that trailing “in this case”. Ah well.

Comments are closed.