Reputation: 24373
I have a directory containing many PNG clip art. I need to delete all that are smaller than 100x100 px. How can I delete them?
Upvotes: 1
Views: 673
Reputation: 121000
for f in `ls`
do
for i in `file $f | cut -f 2 -d ',' | cut -f 2,4 -d ' '` # hsize vsize
do
if [[ $i < 100 ]]
then
rm -rf $f # try echo $i for the dry run
fi
done
done
Upvotes: 1
Reputation: 4069
If you use file
on an image, it gives you that image's dimensions:
$ file yourimage.png
your_directory/yourimage.png PNG image data, 512 x 512, 8-bit/color RGB, non-interlaced
Just parse out the numeric value and determine how you want to keep or delete the image based on the value.
Upvotes: 1