Created
November 25, 2018 11:37
-
-
Save alexarje/3783cb50b9c699eb6cce7c952b732463 to your computer and use it in GitHub Desktop.
Sort images based on direction (portrait/landscape)
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
# Based on: https://unix.stackexchange.com/questions/294341/shell-script-to-separate-and-move-landscape-and-portrait-images | |
# make directories | |
mkdir portraits | |
mkdir landscapes | |
# Check that all images have correct rotation | |
jhead -autorot *.jpg | |
jhead -autorot *.JPG | |
# move files | |
for f in ./*.JPG | |
do | |
r=$(identify -format '%[fx:(h>w)]' "$f") | |
if [[ r -eq 1 ]] | |
then | |
mv "$f" portraits | |
else | |
mv "$f" landscapes | |
fi | |
done | |
for f in ./*.jpg | |
do | |
r=$(identify -format '%[fx:(h>w)]' "$f") | |
if [[ r -eq 1 ]] | |
then | |
mv "$f" portraits | |
else | |
mv "$f" landscapes | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment