Re: Uppercasing filenames
On Sat 20 Sep 2003 17:06:26 +0000(-0400), Jeff Elkins wrote:
> I need to convert a bunch of filenames to uppercase. I tried the script below,
> which does...nothing.
> for file in $*
> if [ -f $file ]
> ucfile=`echo $file | tr [a-z] [A-Z]`
> if [ $file != $ucfile ]
> mv -i $file $ucfile
> Any tips?
If there are any files in the current directory whose names consist of a
single letter, then one or both of [a-z] and [A-Z] (depending on LC_COLLATE)
will be expanded by the shell and the tr command will not receive the
arguments you intended. Try quoting the arguments like this:
tr '[a-z]' '[A-Z]'