Skip to content

Instantly share code, notes, and snippets.

@ArneAnka
Created May 11, 2017 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArneAnka/bf636079faa9df86f7511b38982424ed to your computer and use it in GitHub Desktop.
Save ArneAnka/bf636079faa9df86f7511b38982424ed to your computer and use it in GitHub Desktop.
Search images of a specific dimension
# 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