#!/bin/bash DEFAULT_DEGREES="-90" BAR="##################################################" BARLENGTH=40 DEGREES=$1 WORKING_DIR=$PWD "${DEGREES:=$DEFAULT_DEGREES}" 2>/dev/null if [ ! -x /usr/bin/convert ] ; then echo "Please install convert from ImageMagick!" exit 1 fi IFS=" " echo echo "Rotating all images (*.jpg/*.png) found with these settings:" echo echo " Rotation: $DEGREES" echo " Directory: $WORKING_DIR" echo for dir in $WORKING_DIR/*; do i=0 if [ $( stat -c %F $dir ) == "directory" ] ; then name=$( basename -- "$dir" ) cd $dir 2>/dev/null else name="${PWD##*/}" fi filelist=( `ls *.png *.jpg 2>/dev/null` ) TOTAL=${#filelist[*]} while (($i < $TOTAL)) ; do n=$((i*BARLENGTH / TOTAL)) PROGRESS=$((i * 100 / TOTAL)) tput el tput cr printf "%s [%-${BARLENGTH}s] %3d%%" "${name:0:60}" "${BAR:0:n}" $PROGRESS # Do the converting! convert -rotate $DEGREES ${filelist[$i]} ${filelist[$i]} 2>/dev/null ((i += 1)) done if [ $( stat -c %F $dir ) == "regular file" ] ; then break fi done echo