>Here's a little script I wrote to handle such things.
>for file in $*
>do
> mv -f $file `echo $file | tr '[A-Z]' '[a-z]'` 2>/dev/null 1>&2
>done
>swap the [A-Z] and [a-z] for uppercase/lowercase.
Lose.
How about:
#!/bin/sh
dirname="`echo ${file} | sed -e 's/\/[^\/]*$//'`"
basename="`echo ${file} | sed -e 's/.*\/\([^\/]*\)$/\1/'`"
new_basename="`echo ${basename} | tr '[A-Z]' '[a-z]'`"
if test "z${basename}" = "z${file}" ; then
newname="${new_basename}"
else
newname="${dirname}/${new_basename}"
fi
if test "z${newname}" = "z${file}" ; then
:
else
echo mv "${file}" "${newname}"
fi
done
This is as portable a shell script as you're ever going to see, and it
handle arbitrary filenames correctly, including weird ones with spaces,
etc. in them.