mkdir "portraits"; mkdir "landscapes"; for f in ./*.jpg; do WIDTH=$(identify -format "%w" "$f")> /dev/null; HEIGHT=$(identify -format "%h" "$f")> /dev/null; if [[ "$HEIGHT" > "$WIDTH" ]]; then mv "$f" portraits/ ; else mv "$f" landscapes/ ; fi; done
.jpg
, feel free to change this to .png
or .jpeg
if neccesaryThis relies on the identify
command which comes with ImageMagick which is available on most systems.
This does not check for square images, although it could be easily extended to see if HEIGHT
and WIDTH
are equal. Square images are currently put with the landscape images.