Converting file names to upper case

Hi all,

I am trying to rename all my files in a directory to their upper case counterparts .... I want to do this in a single command and not through shell script ... I started off thinking it wud be simple but got stuck up in middle since tr does not work the way i thought ...

This is what i tried ...

ls | xargs -l1 -t -i mv {} `echo {} | tr '[a-z]' '[A-Z]'`

Here tr does not seem to do any work and just returns the file name as such .. So in effect i am renaming a file to that name itself ...

mv try.cc try.cc
mv: try.cc and try.cc are identical
mv typescript typescript
mv: typescript and typescript are identical

Why is this happening ?? And can anyone suggest me a solution

for i in *
do
mv $i `echo $i|awk '{print toupper($0)}'`
done

now i dunno if you can consider this as a one line command, but i think it has to be, coz you cant execute each of the above line separately by itself to get your result

Not one line, but efficient with ksh builtins...

# ls
file_1  file_2  file_3
# ls | while read filename; do
>    typeset -u uppercase
>    uppercase=${filename}
>    mv ${filename} ${uppercase}
> done
# ls
FILE_1  FILE_2  FILE_3

Cheers
ZB

Here my list of files to be renamed comes from some other command like find or something ... so i wud need to use xargs for doing this Also i want to do rename interactively ....

even when i put this awk part in xargs as below :

ls | xargs -l1 -t -i echo {} `echo {}|awk '{print toupper($0)}'`

awk doesnt work as tr in my first post...

where as here wc works

ls | xargs -l1 -t -i echo {} `echo {}|wc`

Can anyone tell me the reason why this happens ???

Neither command works for me. You must be testing in a directory with only a few two character filenames if you think the second one works. Create a few longer filenames. The shell sees `echo {} | wc`; so it runs that pipeline and it gets "{} 1 1 3" which it replaces in your command. So then you run:
ls | xargs -l1 -t -i echo {} {} 1 1 3

hmm, well if it is output of command find, you can pipe it to a for or while loop as follows, instead of using the xargs.

=>find . | while read a
do
mv "$a" `echo "$a"|awk '{print toupper($a)}'`
done
mv: `.' and `./.' are the same file

if this still doesnt fit in your scenario, tell us what is that makes you so mandatory that you just cant do without using xargs?