[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Rename files



ob6@inf.tu-dresden.de (Oswald Buddenhagen) wrote:
>> On Tue, Mar 21, 2000 at 03:57:14PM +0100, Robert Kasunic wrote:
>> > I'm trying to rename a lot of files. I just want to substitute underlines
>> > with whitespaces. How can I do that?
>> 
>> You might use mmv.
>> 
>> If your files are:  foo_bars
>> then use	   mmv "*_*" '#1\ #2'	(quotes required)
>
>uhmmmm ... i think, that the \ in '#1\ #2' should not be there.
>it's intended to quote the space, but as it is already quoted within "'",
>it will be taken literally.

True, but mmv seems to interpret it itself:

[cjw44@riva ~/test]$ touch foo_bar
[cjw44@riva ~/test]$ mmv '*_*' '#1\ #2'
[cjw44@riva ~/test]$ ls
foo bar

I'd have left out the \ myself, though, as it's potentially confusing; I
think I'd also have used single quotes ('...') around the first argument
because I wasn't intending to do any interpolation in it, but that's
probably just me.

With mmv you can also avoid some quoting issues by supplying arguments
on standard input:

[cjw44@riva ~/test]$ touch foo_bar
[cjw44@riva ~/test]$ mmv
*_* #1\ #2
[press Ctrl-D]
[cjw44@riva ~/test]$ ls
foo bar

This way you don't have to quote asterisks, question marks, hashes, and
the like, but you do still have to escape spaces in arguments with
backslashes.

-- 
Colin Watson                                           [cjw44@cam.ac.uk]


Reply to: