Maybe I should 've put this under 'Multimedia', but still,
hereby a full bash script I've written (and translated from my mother tongue) to seperate horizontal (landscape) or vertical (portrait) pictures from one dir to a 'Landscape' and a 'Portrait' dir.
I've named the script '0000_Photos_Sort_to_Portrait_or_Landscape.sh' (starting with 0000 to make it land on top of the input dir)
Tweak to your personal desires.
Give the script convenient rights.
Reply if you see sth that could be done in a better way.
Code: Select all
#!/bin/bash
echo -en '\e[8;14;80t' # Window Size
TITEL="PHOTOS - SORT TO PORTRAIT OR LANDSCAPE"
echo -en "\033]0;$TITLE\a" # Window Title
clear
echo "$TITLE"
echo
echo "Place this script in a dir with horizontal and vertical photos."
echo "A new folder will be created for each type."
echo "Makes use of imagemagick resolution recognition."
echo
echo "Source Extension (Default jpg, without dot)?"
read -e -i "jpg" -p "" SOURCEEXT
echo
# Codes:
mkdir -p Portrait
mkdir -p Landscape
for f in ./*.${SOURCEEXT}
do
r=$(identify -format '%[fx:(h>w)]' "$f")
if [[ r -eq 1 ]]
then
echo "Vertical pictures moved to folder Portrait..."
mv "$f" ./Portrait/
else
echo "Horizontal pictures moved to folder Landscape..."
mv "$f" ./Landscape/
fi
done
echo
echo "Enter = Reload Script"
echo "Ctrl+c or Close button = Close"
read
exec bash "$0" "$@" # Restart script from the beginning