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

moving lowercase to uppercase files

Status
Not open for further replies.

mckarl

Programmer
May 5, 1999
147
GB
hi there, i have a small quiz for you all, <br>
<br>
i need to change many files from lowercase to uppercase... <br>
<br>
EG:<br>
<br>
<br>
file1.cpy TO FILE1.cpy<br>
file2.cpy TO FILE2.cpy<br>
<br>
i need the .cpy (copybooks) to stay LOWERCASE and the other from lower to uppercase. <br>
There are many files, and i do not whish to rename them all :)) what about awk or something?? anyone <br>
<br>
thanks... karl<br>
<p> <br><a href=mailto:mc_karl@yahoo.com>mc_karl@yahoo.com</a><br><a href=karls-stuff.co.uk>my stuff :)) WINProducts & stuff</a><br>- Karl<br>
<br>
- <b> the </b> damn good lookin' one ;)
 
What about:<br>
<br>
#!/bin/ksh<br>
<br>
typeset -l LowerCase<br>
<br>
for File in *.cpy<br>
do<br>
LowerCase=$File<br>
if [[ ! -f $LowerCase ]]<br>
then<br>
mv $File $LowerCase<br>
fi<br>
done<br>
<br>
Hope this helps,<br>
Patrice. <p>Patrice ALLAIS<br><a href=mailto:allais@lucent.com>allais@lucent.com</a><br><a href= > </a><br>
 
Allais... thanks for the reply... i tried the script.. and after modifying it to change to <b>uppercase</b> :)) it worked fine... <br>
<br>
<i>Except</i> I need it to leave the .cpy <b>lowercase</b>..<br>
<br>
hmm...... is it possible that it will change up only to the full-stop?... using $1 or something... <br>
<br>
Thanks for the reply... and i am testing a few things out... <br>
<br>
<br>
Have Fun... Karl.<br>
<br>
<p> <br><a href=mailto:mc_karl@yahoo.com>mc_karl@yahoo.com</a><br><a href=karls-stuff.co.uk>my stuff :)) WINProducts & stuff</a><br>- Karl<br>
<br>
- <b> the </b> damn good lookin' one ;)
 
I knew I'd seen it somewhere.<br>
<br>
Try this;<br>
<br>
--snip--<br>
# a loop where $f is set to each filename matching *.CPY:<br>
for f in *.CPY<br>
do<br>
&nbsp;&nbsp;&nbsp;&nbsp;nf=$(print $f ¦ tr [a-z] [A-Z])<br>
&nbsp;&nbsp;&nbsp;&nbsp;nf=$(print ${nf%.CPY}).cpy<br>
&nbsp;&nbsp;&nbsp;&nbsp;mv $f $nf<br>
done<br>
--snip--<br>
<br>
You could rename a lot of files like this - so go carefully.<br>
<br>
Mike<br>
<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= > </a><br>
 
using the script submitted by allias, typesetting to uppercase, of course, add an entry that crops the .cpy from the variable thusly:<br>
${File}=${File%%.cpy}<br>
before doing the LowerCase=$File thing (or UpperCase if you changed your variables to match your intention).<br>
Of course, you need to change the mv command to reflect the lack of .cpy in the ${File} variable to:<br>
mv ${File}.cpy ${UpperCase}.cpy
 
Thanks Dstar. Thanks lads, thanks everyone. i have now solved my problem... and about to post a new one :))<br>
<br>
- Karl<br>
<p> <br><a href=mailto:mc_karl@yahoo.com>mc_karl@yahoo.com</a><br><a href=karls-stuff.co.uk>my stuff :)) WINProducts & stuff</a><br>- Karl<br>
<br>
- <b> the </b> damn good lookin' one ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top