Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing case of files.

Status
Not open for further replies.

StickyBit

Technical User
Jan 4, 2002
264
CA
Hi folks,

I have been working with Unix for a short while, and I have a small problem. I have a directory with lots of html files in it that are all in upper case. I would like to change the case of all the files to lower case. How can I accomplish this, please help.

Stickybit
 
How about this ...
[tt]
#!/bin/sh
cd html-dir
for F in `ls`
do
Flow=`echo $F | tr "[A-Z]" "[a-z]"`
mv $F $Flow
done
[/tt](thanks to trunix for reminding me of "tr" - always forgetting that useful guy ;-))
One by one, the penguins steal my sanity. X-)
 
This short script should do it for you .

for file in `ls -1`
do
echo $file > tmp_file
mv $file `tr &quot;[:upper:]&quot; &quot;[:lower:]&quot; < tmp_file`
done

An explanation :-
ls -1 produces a list of filenames
These are placed one at a time into tmp_file
The mv command renames the original file to a new name
which is produced from the tr command which changes upper case to lower case.

I would recommend that you test this on some dummy files before using it, and as always .... backup your files before changing them.


 
ayjaycee....

You just got in before me !
I also used tr but in a different way.....

One problem ...... many solutions !

Trunix
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top