Page 1 of 1

Replace one word with multiple words w/ BatchSubstitute.bat?

Posted: 14 Jan 2010 20:38
by sj10
I am trying to replace a single word in a file with multiple words (a multi-word string of text). I imagine it's easy but have not yet cracked it.

For example, replace the string "Yellow Submarine" with "Blue Submarine" in color.txt and pipe it into a new file called newfile.txt.

Below are my two attempts, and the error messages returned in each case.

(1.) I tried:
BatchSubstitute.bat "Yellow Submarine" "Blue Submarine" color.txt>newfile.txt

This was returned:
Submarine" "Blue was unexpected at this time.

(2.) I tried:
BatchSubstitute.bat "Yellow Submarine" Blue Submarine color.txt>newfile.txt

This was returned:
Submarine" Blue Submarine color.txt"=="" was unexpected at this time.

I'm not a programmer (former web developer/HTML coder actually) and I don't know VB. I would like to do this with BatchSubstitute.bat if possible.

Any help appreciated!

Steve

Posted: 16 Jan 2010 00:11
by DosItHelp
sj10,

There is actually a bug in the batch file. To fix this replace the IF statement in the batch script from:

if "%*"=="" findstr "^::" "%~f0"&GOTO:EOF
to:
if "%~1"=="" findstr "^::" "%~f0"&GOTO:EOF

Let me know if it works for you.
Thanks.