Artificial intelligent assistant

Shell script to separate and move landscape and portrait images I have a directory of `jpg` images. Is there a shell script (`bash` or `zsh` would be acceptable) that would move all landscape images into a directory, and all portrait images into another directory?

You could use `imagemagick`'s `identify` with the `fx` special operator to compare height and width e.g. check `h/w` ratio:


for f in ./*.jpg
do
r=$(identify -format '%[fx:(h/w)]' "$f")
if (( r > 1 ))
then
mv "$f" /path/to/portraits
elif (( r < 1 ))
then
mv "$f" /path/to/landscapes
fi
done
# mv ./*.jpg /path/to/squares


This leaves the square images in the current directory. Uncomment the last line to move them to their own directory. Or, if you wanted to include them to either landscapes or portraits, change one of the comparison operators to either `<=` or `>=`.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 831b1341b22dca6e9fe6dfdfe954dc2e