home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!udecc.engr.udayton.edu!blackbird.afit.af.mil!dsacg3.dsac.dla.mil!dsac.dla.mil!hq.dla.mil!fazc016
- From: fazc016@hq.dla.mil (Don Costello)
- Newsgroups: comp.unix.questions
- Subject: Re: need script to rename uppercase filenames
- Message-ID: <866@hq.dla.mil>
- Date: 3 Sep 92 17:10:19 GMT
- References: <699@svcs1.UUCP>
- Organization: HQ Defense Logistics Agency/DASC, Cameron Station, VA
- Lines: 50
- X-Newsreader: Tin 1.1 PL4
-
- slix@svcs1.UUCP (Bill Miller) writes:
- : Hi, everyone.
- :
- : I'm fairly new to unix, and I need a script or procedure to do the following:
- :
- : I have some source code in DOS (many separate files) that I tarred under
- : DOS and untarred under 386BSD. The big problem is that all the files
- : came through in UPPERCASE and I need a script to mv (rename) them all
- : to lowercase quickly.
- :
- : Since they're in DOS text format, I realize I also need to strip the
- : extra carriage returns on each line. I've been successful in doing this
- : with:
- :
- : cat (file) | tr -d '\015' > (newfile)
- :
- : It would be nice to combine both of these so that I could rename the
- : files to uppercase and strip the extra newlines all in one fell swoop
- : instead of doing it one file at a time.
-
- I'm assumming you want to rename the files FROM upper TO lower
- case...
-
- Use "tr" like you did above to change the filename. The following works
- on BSD4.3:
-
- #!/bin/sh
- #
- for oldfname in *
- do
- cat $oldfname | tr -d '\015' > `echo $oldfname | tr [A-Z] [a-z]`
- done
-
- You still have to remove the "$oldfname" before you end. I really
- don't think there is a way to do it all at once because you are
- reading the *contents* of the file and sending the lines, less the
- "^M", to a newfile (lowercase of the original).
-
- My suggestion for the future... PKZip the files on your PC, then UnZip
- (using Info-Zip "unzip") and the files will be lower case and the CR/LF
- translated correctly.
-
- But then again, your question breeds shell practice... :-)).
-
- Cheers -- dcc --
- --
- +------------------------------------+---------------------------+
- | Don Costello, DASC-ZSC | It's hard to cram this |
- | DLA Cameron Station, VA | signature into just 4 |
- | TEL: (703) 274-7215 AV: 284-7215 | lines!!! |
-