Find and remove all photos below a certain size threshhold So, I had a relative's hard drive collapse, and I've used photorec to look for the most obvious files to retain (fortunately they only had pictures on the computer, everything else was cloud-synced, such as email) so I now have a parent-folder with 208 subfolders of all the PNG and JPG files from the old drive. Obviously a lot will be either "OS and Application images" (toolbars, sample images, thumbnails, system caches) and some will be "family photos".

If I can find some way to find all below a certain size (preferably say 300px wide) then sorting the rest should * be easy. 

How can I use iPhoto or Spotlight or something to do this automatically? I'm also open to scripts using easily installed (brew perhaps?) libraries, if a script of some sort can be pointed to.

* famous last words
You can use the terminal to do this. The following command should work:

find /path/to/the/folder \
  -name "*.jpg" \
  -exec bash -c "sips -g pixelHeight -g pixelWidth {} | grep -E ' [12]?[0-9]{0,2}$' &gt;/dev/null" \;\
  -print 


That command will find all JPEG files under /path/to/the/folder which have a width or a height of between 1 and 299 pixels.

Replace /path/to/the/folder with the actual path to your folder.

You can change "*.jpg" to "*.gif" to find GIF files instead.

You can change [12]?[0-9]{0,2} to change the size of the pictures you wish to locate. For example, to find pictures smaller than 500 pixels, use [1234]?[0-9]{0,2}

If you want to review which pictures this command finds, use:

find /path/to/the/folder \
  -name "*.jpg" \
  -exec bash -c "sips -g pixelHeight -g pixelWidth {} | grep -E ' [12]?[0-9]{0,2}$' &gt;/dev/null" \; \
  -exec mv {} /path/to/some/other/folder \; 


Replace path/to/some/other/folder with the folder you want the files moved to, and that command will move the files it finds there.



The way this works is as follows:

The sips command is the scriptable image processing system. The terminal command sips -g pixelHeight -g pixelWidth some.jpg will print out the width and height of the JPEG file.

The find command, as one might expect, finds files. -exec passed to find tells find to execute the specified command and only return files for which the command returns a successful result.

The command bash -c "sips -g pixelHeight -g pixelWidth {} | grep -E ' [12]?[0-9]{0,2}$' invokes a shell, runs sips to get the image size, and then runs grep, which searches text, asking grep to search for either a 1 or a 2 followed by between zero and two digits (0 through 9). This is a regular expression, and it matches the numbers (strings) 1 through 299