#!/bin/sh
ROT=$1
shift
while test -f "$1"
do
		if [ "$ROT" = "fliphor" ]
		then
			echo flipping hor
 			`jpegtran -copy all -flip horizontal -outfile rotate "$1"`
			`mv rotate "$1"`
		else	
			if [ "$ROT" = "flipver" ]
			then
				echo flipping ver
				`jpegtran -copy all -flip vertical -outfile rotate "$1"`
	                        `mv rotate "$1"`
	               	else
				echo "rotating2 $ROT"
			        `jpegtran -copy all -rotate $ROT -outfile rotate "$1"`
	        		`mv rotate "$1"`
			fi
		fi
	shift
done
