home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!walter!fork!snk
- From: snk@fork.bae.bellcore.com (Samuel Kamens)
- Subject: Re: need script to rename uppercase filenames
- Message-ID: <1992Sep3.135042.29363@walter.bellcore.com>
- Keywords: script,tar,msdos
- Sender: news@walter.bellcore.com
- Nntp-Posting-Host: fork.bae.bellcore.com
- Reply-To: snk@bae.bellcore.com
- Organization: Bell Communications Research
- References: <699@svcs1.UUCP>
- Date: Thu, 3 Sep 92 13:50:42 GMT
- Lines: 52
-
- In article <699@svcs1.UUCP>, 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.
- >
-
-
- Try this:
-
- -------------------- CUT HERE ----------------------
- #!/bin/ksh
- # Script to rename a list of files to its lowercase equivalent while
- # stripping extra carriage returns
- #
-
- USAGE: $0 FILE1 FILE2 FILE3 ...
-
- for i in $*
- do
- lowfile=`echo $i | tr [A-Z] [a-z]`
-
- cat ${i} | tr -d '\015' > ${lowfile}
- # you could do rm $i here if you want
- done
- -------------------- CUT HERE ----------------------
-
- You could also do this with a one-liner:
-
- cat $1 | tr -d '\015' > `echo $1 | tr [A-Z] [a-z]`
-
- Sam
-
- --
- Sam Kamens Bell Communications Research
- snk@bae.bellcore.com Phone: (908) 699-7509
- 444 Hoes Lane Room RRC 1D-210
- Piscataway, NJ 08854
-