Re: Uppercasing filenames
* Jeff Elkins <jeffelkins@earthlink.net> [2003-09-20 13:07]:
> I need to convert a bunch of filenames to uppercase. I tried the
> script below, which does...nothing.
>
> #!/bin/sh
> for file in $*
> do
> if [ -f $file ]
> then
> ucfile=`echo $file | tr [a-z] [A-Z]`
> if [ $file != $ucfile ]
> then
> mv -i $file $ucfile
> fi
> fi
> done
>
> Any tips?
If I may, try the following:
#v+
#!/bin/sh
for file in *
do
ucfile=`echo $file | tr [:lower:] [:upper:]`
if [ -f $file ] && [ ! $ucfile -ef $file ]
then
cp $file $ucfile
fi
done
#v-
That's assuming that you want any files with all uppercase filenames to
be ignored. The only syntactical error that I saw was the '$*' instead
of '*' on the first non-comment line.
HTH,
--
dave [ please don't CC me ]
Reply to: