#!/bin/sh

# will convert specified files to uppercase names

if [ "$1" = "-r" ] ; then
	recurse=1; shift;
else
	recurse=0;
fi;

for x in $* ; do
	if [ -r "$x" ] ; then
		conv="`echo $x | tr '[a-z]' '[A-Z]'`";
		if [ "$x" != "$conv" ] ; then
			if [ -e $conv ] ; then
				echo "ERROR: $conv already exists (from $x)";
				echo "exiting..."
				exit 1;
			fi;
			mv "$x" "$conv";
		fi;
		if [ $recurse -gt 0 -a -d "$conv" ] ; then
			$0 -r $conv/*;
		fi;
	fi;
done;
