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

Re: regexp for rename command - please help!



On Sat, 20 Feb 2010 09:44:29 -0500 (EST), Vadkan Jozsef wrote:
> 
> The filename, that i want to rename:
> 
> ---vol.-01-disk-cantatas-bwv-3;
> 
> commands, that doesn't work:
> 
> $ rename 's/^---//g' *
> Unknown option: -vol.-01-disk-cantatas-bwv-3;
> Usage: rename [-v] [-n] [-f] perlexpr [filenames]
> 
> 
> $ rename 's/.-/-/g' *
> Unknown option: -vol.-01-disk-cantatas-bwv-3;
> Usage: rename [-v] [-n] [-f] perlexpr [filenames]
> 
> 
> $ rename 's/;$//g' *
> Unknown option: -vol.-01-disk-cantatas-bwv-3;
> Usage: rename [-v] [-n] [-f] perlexpr [filenames]
> 
> 
> What is the regexp to get this filename?:
> 
> vol-01-disk-cantatas-bwv-3
> 
> Thank you:)

I guess I'm not really sure what you want, but if all you want
to do is rename

   ---vol.-01-disk-cantatas-bwv-3;

to

   vol-01-disk-cantatas-bwv-3

The command is

   mv -- ---vol.-01-disk-cantatas-bwv-3\; vol-01-disk-cantatas-bwv-3

Two things are significant.  First, the double hyphen (--) after mv
tells mv that this is the end of the options list and anything after
it that starts with a hyphen is to be interpreted as a command
argument instead of a command option.  Second, the backslash (\) in front
of the semicolon (;) causes the semicolon to be interpreted by the shell
as part of the filename and not as a command separator.  Normally,
the semicolon is used to separate multiple commands on a single line.


Reply to: