CHANGING file names - (small to CAPITOL)

Dan Mercer mercer at npdiss1.StPaul.NCR.COM
Sat Dec 22 05:10:23 AEST 1990


In article <josef.661159919 at ugum01> josef at nixpbe.nixdorf.de (josef Moellers) writes:
:In <110800 at convex.convex.com> tchrist at convex.COM (Tom Christiansen) writes:
:
:>In article <10617 at uhccux.uhcc.Hawaii.Edu> kyung at uhccux.UUCP (Kyung Lee) writes:
:>:	Hi everyone, since unix is case sensitive, I'm having some
:>:	problem with file names...small and CAPs.
:
:>This is a feature.
:
:>:	Has anyone ever come up with a program that renames all the
:>:	files in a directory from small letter to CAPs??
:
:>That's not the way most people want it changed, you know.  Who
:>wants all those ugly capitals anyway?  
:
:Try
:% for file in *
:> do cap=`echo $file | tr '[a-z]' '[A-Z]'`
:> mv $file $cap
:> done
:%
:
:--
:| Josef Moellers		| c/o Siemens Nixdorf Informationssysteme AG |
:|  USA: mollers.pad at nixdorf.com	| Abt. STO-XS 113			     |
:| !USA: mollers.pad at nixdorf.de	| Heinz-Nixdorf-Ring			     |
:| Phone: (+49) 5251 104662	| D-4790 Paderborn			     |

There is a far more efficient method:

<set -- `echo * | tr "[a-z]" "[A-Z]"`
<for i in *
<do
<mv $i $1
<shift
<done

This eliminates the need to load tr for each and every file

-- 
Dan Mercer
NCR Network Products Division      -        Network Integration Services
Reply-To: mercer at npdiss1.StPaul.NCR.COM (Dan Mercer)
"MAN - the only one word oxymoron in the English Language"



More information about the Comp.unix.programmer mailing list