LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Converting file names to uppercase (https://www.linuxquestions.org/questions/linux-newbie-8/converting-file-names-to-uppercase-691662/)

mmahulo 12-19-2008 05:28 AM

Converting file names to uppercase
 
Hi

Please help me in converting lower case filenames to uppercase.
The following is what I've attempted and it seems not to work:

cd /home/temp # going into the temp directory where the files are located
for file in *.file
do
tr [:lower:] [:upper:]
done


Please help..!!!

zoran119 12-19-2008 05:52 AM

Quote:

Originally Posted by mmahulo (Post 3380997)
Hi

Please help me in converting lower case filenames to uppercase.
The following is what I've attempted and it seems not to work:

cd /home/temp # going into the temp directory where the files are located
for file in *.file
do
tr [:lower:] [:upper:]
done


Please help..!!!

maybe

for file in *.file
do
mv $file `echo $file | tr [:lower:] [:upper:]`
done

radoulov 12-19-2008 05:53 AM

Code:

perl -e'
  map { rename $_, "\U$_" } glob "*"
  '


pixellany 12-19-2008 06:26 AM

Quote:

Originally Posted by mmahulo (Post 3380997)
Hi

Please help me in converting lower case filenames to uppercase.
The following is what I've attempted and it seems not to work:

cd /home/temp # going into the temp directory where the files are located
for file in *.file
do
tr [:lower:] [:upper:]
done


Please help..!!!

In the line highlighted above, you don't send any data to tr, and you don't do anything with the output. (zoran gives an example that shows one way to do it.)

One trick in writing scripts is to first test each individual command to be sure you know what it does.

mmahulo 12-19-2008 06:37 AM

Thanks zoran119
That mv command worked perfectly for me. Thanks to you all!

ciden 12-19-2008 07:28 AM

Thanks to this i learnt something new.


All times are GMT -5. The time now is 02:49 AM.