Skip to content

Instantly share code, notes, and snippets.

@uriel1998
Created November 17, 2012 01:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uriel1998/4092500 to your computer and use it in GitHub Desktop.
Save uriel1998/4092500 to your computer and use it in GitHub Desktop.
Small bash script to remove small cover images (or really, any small resolution images)
#! bin/bash
cd ~/Music
echo "Run this script from your base music directory (or wherever you want to purge png and jpg images from)"
echo "Currently in $PWD"
echo "What is the minimum resolution you want?"
read request
# test for number without decimal
if [ "$request" -eq "$request" ] 2>/dev/null; then
echo "Finding jpg covers."
find . -iname "*.jpg" -exec ls -f '{}' \; > tempfile.txt
echo "Finding png covers."
find . -iname "*.png" -exec ls -f '{}' \; >> tempfile.txt
echo "testing covers..."
while read line; do
# tmp=$(identify $line | awk '{print $3}' | awk -F 'x' '{ print $1 "/" $2 }')
tmp=$(identify "$line" | awk '{print $3}' | awk -F 'x' '{ print $1 }')
if [ "$tmp" -lt "$request" ]; then
icky=$(basename "$line")
echo "File $line has resolution of $tmp,"
echo "which is less than requested resolution of $request; deleting."
fullpath=$(realpath "$line")
echo "$fullpath"
rm -f "$fullpath"
fi
done < tempfile.txt
else
echo "That isn't a number."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment