LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-19-2008, 06:28 AM   #1
mmahulo
Member
 
Registered: Nov 2008
Posts: 31

Rep: Reputation: 15
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..!!!
 
Old 12-19-2008, 06:52 AM   #2
zoran119
Member
 
Registered: Dec 2007
Posts: 217

Rep: Reputation: 18
Quote:
Originally Posted by mmahulo View Post
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
 
Old 12-19-2008, 06:53 AM   #3
radoulov
Member
 
Registered: Apr 2007
Location: Milano, Italia/Варна, България
Distribution: Ubuntu, Open SUSE
Posts: 212

Rep: Reputation: 36
Code:
perl -e'
  map { rename $_, "\U$_" } glob "*"
  '
 
Old 12-19-2008, 07:26 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by mmahulo View Post
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.
 
Old 12-19-2008, 07:37 AM   #5
mmahulo
Member
 
Registered: Nov 2008
Posts: 31

Original Poster
Rep: Reputation: 15
Thanks zoran119
That mv command worked perfectly for me. Thanks to you all!
 
Old 12-19-2008, 08:28 AM   #6
ciden
Member
 
Registered: Dec 2006
Location: New Delhi, India
Distribution: PCLinuxOS 2010
Posts: 246
Blog Entries: 1

Rep: Reputation: 31
Thanks to this i learnt something new.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to change file names to uppercase in a directory konramesh Linux - General 4 06-16-2009 07:13 AM
uppercase letters in user/group names Sadus Linux - Security 1 09-17-2007 08:47 AM
Krename & converting file names STARHARVEST Linux - Software 4 11-27-2006 10:02 AM
Converting Uppercase to Lowercase AMMullan Linux - Software 6 10-18-2005 08:32 PM
Converting lowercase to uppercase noodle123 Programming 1 05-17-2002 03:12 PM


All times are GMT -5. The time now is 02:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration