From 6a9754a560499ee9119541dd22e6e70f2df6ff40 Mon Sep 17 00:00:00 2001 From: Joshua Pickard Date: Wed, 30 Mar 2022 19:57:19 +0000 Subject: [PATCH] Add 'sortbyorientation.sh' --- sortbyorientation.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 sortbyorientation.sh diff --git a/sortbyorientation.sh b/sortbyorientation.sh new file mode 100644 index 0000000..ce99b3d --- /dev/null +++ b/sortbyorientation.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +mkdir portraits +mkdir landscapes + +jhead -autorot *.jpg +jhead -autorot *.JPG +jhead -autorot *.png +jhead -autorot *.PNG + +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 + +for f in ./*.png +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 ./*.PNG +do + r=$(identify -format '%[fx:(h>w)]' "$f") + if [[ r -eq 1 ]] + then + mv "$f" portraits + else + mv "$f" landscapes + fi +done \ No newline at end of file