Created
May 11, 2017 11:42
-
-
Save ArneAnka/bf636079faa9df86f7511b38982424ed to your computer and use it in GitHub Desktop.
Search images of a specific dimension
This file contains hidden or 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
# This scripts helps you when seraching images of a speceifc dimension. Lets | |
# say you want to remove thumbnails or something, then this is good! | |
# Notice the `echo`, remove that and run the script. That will REMOVE you files. | |
# Change `rm` to `cp` to copy the files if you want to review them before deletion. | |
``` | |
#!/bin/bash | |
targetDir="$HOME/Pictures" | |
find "$targetDir" -iname '*.jpg' -o -iname '*.png' -o -iname '*.bmp' -o -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 270 ]] && [[ $w -eq 360 ]]; then | |
echo rm "$filename" | |
fi | |
done | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment