: # NAME: # mkrotate - make the list of rotations # # SYNOPSIS: # mkrotate # # DESCRIPTION: # This script prompts the user with .jpg file in the current # directory and asks for the rotation required. # At the prompt the user can enter 0, 90, -90 to indicate the # rotation desired, or newline to accept the default. If the # user enters the name of a .jpg file, we skip all others until # we find that one and then start prompting again. # If the user enters 'q' we stop. # # Finally we print out the appropriate rm(1) commands to removed # the previous -[tw].jpg files so that photoweb(1) will # re-create them with the now correct rotations. # # SEE ALSO: # photoweb(1), mpics.pl(1). # # AUTHOR: # Simon J. Gerraty # # RCSid: # $Id: mkrotate,v 1.4 2001/12/11 08:08:48 sjg Exp $ # # @(#) Copyright (c) 2000 Simon J. Gerraty # # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. # Permission to copy, redistribute or otherwise # use this file is hereby granted provided that # the above copyright notice and this notice are # left intact. # # Please send copies of changes and bug-fixes to: # sjg@crufty.net # Mydir=`dirname $0` case "$Mydir" in /*) ;; *) Mydir=`cd $Mydir; pwd`;; esac PATH=$Mydir:$PATH:/etc/rc_d . ask.sh R=.rotate lr=0 skipto=`[ $# = 0 -a -s $R ] && tail -1 $R | cut -d: -f1` for f in ${*:-*[0-9].jpg} do [ -f $f ] || continue case "$skipto$f" in $f|$f$f) skipto=;; *) continue;; esac ask r "$f [$lr]" case "$r" in "") r=$lr;; 0*) lr=$r; continue;; *.jpg|*.tif) skipto=$r; continue;; [1-9][0-9][0-9][0-9]*) skipto=$r.jpg; continue;; [qQ]*) break;; rm) rm -i $f;; esac case "$r" in 0*) continue;; esac echo "$f:$r" >> $R.new lr=$r done if [ -s $R.new ]; then sed -n 's,^\(.*\)\(\.jpg\).*,rm -f \1-?\2,p' $R.new [ -s $R ] && mv $R $R.old || touch $R.old sort -nu $R.old $R.new > $R fi rm -f $R.new