Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!brutus.cs.uiuc.edu!rpi!tale From: tale@cs.rpi.edu (Dave Lawrence) Newsgroups: comp.unix.questions Subject: Re: Changing upper-case filenames to lower-case Message-ID: <%#|3F@rpi.edu> Date: 7 Dec 89 09:26:39 GMT References: <3116@jarthur.Claremont.EDU> <5249@omepd.UUCP> <25747F32.4268@ateng.com> <1989Dec7.020047.8178@sq.sq.com> Distribution: na Organization: Rensselaer Polytechnic Institute, Troy NY Lines: 44 According to merlyn@iwarp.intel.com (Randal Schwartz): RandalL> perl -e 'for$f(<*>){($_=$f)=~y/A-Z/a-z/;rename($f,$_)unless$f eq$_;}' In article <25747F32.4268@ateng.com> chip@ateng.com (Chip Salzenberg) writes: Chip> I'd think that "<*>", which runs "/bin/sh echo", should be avoided. Chip> [much longer solution deleted] In <1989Dec7.020047.8178@sq.sq.com> lee@sq.sq.com (Liam R. E. Quin) writes: Liam> Er, am I missing something? Yes. Liam> for i in * Liam> do Liam> mv $i `echo $i | tr '[A-Z]' '[a-z]'` Liam> done Fine. I have a directory with 400 files in it that I want to convert this way. You just soaked up 800 processes. The perl solution used two (that is, as long as Chip is right about the /bin/sh, and I don't have any reason to doubt him). Depending on the limitations of your sh, too, the * expansion might break in both your version and the original perl example. Liam> Is the issue really minimising the number of characters typed, Liam> getting the most easily understood solution, or simply doing as Liam> much as possible in perl? RandalL offered the perl solution both to continue his presence as the man who can make perl do anything but buy him dinner and to show an efficient way of handling multiple files, since perl uses the unlink(2) call directly. Chip followed up on RandalL's efficiency offering by not only doing the unlink() calls from perl, but the reading of the directory file too. This puts it into one process, no matter the size of the directory. Both RandalL's and Chip's messages were pretty clear about why they were being offered. Dave -- (setq mail '("tale@cs.rpi.edu" "tale@ai.mit.edu" "tale@rpitsmts.bitnet"))