Created
November 17, 2012 01:34
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! 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