So a few years ago a asked this question, on how to find an image of specific dimensions. That script worked (and works) great for me! But now, i want to find not just one (1) dimensions but 10 different dimensions. And with my current setup and system, and iteration of a specific dimensions takes about one (1) hour.
I have multipel executables of the same script, but i run them after each other ./delete180x180images && ./delete800x600images
and so on.
Is it possible to compare the image dimensions agains an array? example DIMENSIONS=('120x120' '269x360' '360x269')
, and if there is a match, move that file?
This is the script from my previous question that i currently use:
#!/bin/bash
targetDir="$HOME/Pictures/iPhoto-bibliotek.photolibrary"
HEIGHT=450
WIDTH=600
echo -e "Scanning \033[0;32m$targetDir\033[0m"
find $targetDir -type f \( -iname \*.jpg -o -iname \*.png -iname \*.bmp -iname \*.jpeg \) 2>/dev/null | \
while read -r filename; do
hw="$(sips -g pixelHeight -g pixelWidth "$filename" 2>/dev/null)"
h="$(awk '/pixelHeight/{print $2}'<<<"$hw")"
w="$(awk '/pixelWidth/{print $2}'<<<"$hw")"
if [[ $h -eq $HEIGHT ]] && [[ $w -eq $WIDTH ]]; then
echo mv "$filename" $(pwd)/120x120images
fi
done
Best Answer
You can add additional dimensions in the same way, or change the target directory if required. Also, remove the
echo
once it works.