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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change the directory name from lower case to upper case, pls help... 1

Status
Not open for further replies.

hendnov

Technical User
Feb 27, 2006
73
AU
Hi guys,

I've got real problem. which is all my data which is (file and directory name) in all lower case but I need them in upper case.

So do you guys have any idea to make script to shift the file and directory name from lower case to upper case pls ??

Much appreaciated guys
 
#!/bin/sh
for i in *
do
j=`echo $i | tr '[a-z]' '[A-Z]'`
mv $i $j
done

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
BTW the script above doesn't check to see if the upper case filename already exists and isn't recursive.

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
or

find . -type -f -name \* |sort -r|awk '{f=toupper($1);if(f!=$1 && p[f]!=1){print "mv -i "$1" "f}p[$1]=1}'

Not tested

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
PErhaps something like this ?
find . | sort -r | awk '/[a-z]/{printf "mv \"%s\" \"%s\"\n",$0,toupper($0)}' | sh

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thx guys, I'll try tomorrow morning...

Appreciate that
 
Hi guys,

Thx for your input, but your command is just print out. And I'm quite happy about it.

Just wondering how if I want to execute it.

THX guys,
 
Seems you haven't tried my suggestion ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I did PHV,

but without SH at the back, coz it generated error.
and they print out all the command such as :

mv test TEST
mv Makanan MAKANAN

I'm happy about the result and I want to execute it now ?? how ??

 
What error do you get with sh at the end?

Try

Redirect it using

> filename.sh

at the end of PHV's command line

then

chmod 700 filename.sh

then execute it

. ./filename.sh


Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top