How to replace underscores with other characters in a filename?

From: 0 (stacko23_at_my-deja.com)
Date: 12/21/03


Date: 21 Dec 2003 08:39:56 -0800

Hi NG!
I've got some files named "Title _Author_ _blah_.rar" and I'd like to
rename them at once in "Title (Author) (blah).rar" ot something like
that. Notice that the underscores are not replaced by a single
character but that it depends on the leading or trailing space
character.
How can I do this quickly, without creating some perl script or
something similar for the purpose? I've been thinking of a bash
script, but I'm rather reserved as of using bash because it instantly
gives me an awful headache when trying to grasp it's awful syntax.
Well I know I shouldn't but maybe you could achieve convincing me to
think of bash as of a delicious ice cream (mmmmmhh.... bash...) by
showing me how impressingly simple it is to do the renamings?
My apologies if I sound a bit confusing, but anyway: any help would be
greatly appreciated.

Thanks!
Bernd Haller



Relevant Pages

  • Re: sed backreference question
    ... It stems from ... > the fact that I'm using a Bourne shell script, not bash. ... > character stored in what should be an empty variable. ...
    (comp.unix.shell)
  • Re: Read Write serial port
    ... >> That doesn't correspond to what you are doing in bash. ... is the character with the numerical value 0, ... simple arrays. ...
    (comp.lang.c)
  • Re: Literal square brackets in Bash
    ... brackets from external text files. ... well as online research, I'm no closer to a solution than I was at the ... [is simply a character. ... I've been using Bash exclusively for this. ...
    (uk.comp.os.linux)
  • Re: What is the rule of terminal special characters
    ... that does mean vim resets the keycode when it starts ... tells the terminal driver upon which character it should perform ... neither bash nor vim use that canonical mode as they ... with stty erase '^?'. ...
    (comp.unix.shell)
  • Re: special charcthers
    ... You need either to tell your terminal to send the 162 character ... bash upon the pressing of a key or key combination and tell bash ... You may prefer using zsh: ... (Note that I chose ^KCt because it is the character sequence ...
    (comp.unix.shell)