Walt Mankowski on Mon, 4 Nov 2002 21:08:06 -0500 |
On Mon, Nov 04, 2002 at 08:21:49PM -0500, gabriel rosenkoetter wrote: > On Mon, Nov 04, 2002 at 07:20:18PM -0500, Bill Jonas wrote: > > (Incidentally, this is why you can say something like 'ren *.foo *.bak' > > and actually have it work, whereas in a *nix-based system you would have > > to use a for loop. This, IMO, is the *only* redeeming feature of not > > having the shell process the wildcards.) > > That's neat, but what happens if your destinations are extant files, > not ones you're creating, and input doesn't map cleanly to output? The DOS ren command is short for rename, and as the name suggests it rename files. The syntax Bill gave is a shorthand that renames all the files ending in ".foo" so that they end in ".bak". Since the shell doesn't expand filenames, all the logic to do that has to be inside the rename command. BTW, if you ever need to do something like 'mv *.foo *.bar' in Unix, there's a great perl script written by Larry Wall (yes, *the* Larry Wall) called 'rename' that lets you rename files using Perl regular expressions. For example, you could say rename 's/.foo$/.bar/ *.foo rename ships with Debian's perl package. I'm not sure where else it's available. Walt Attachment:
pgp5g4Cjub9st.pgp
|
|