Hello,
What is the magic parameter to use in BatchSubstitute to replace double-quotes (") in a string? I have tried all manner of escape characters, and I cannot replace the double-quotes throughout my file.
Thanks,
Steve
Replacing Double Quotes using BatchSubstitute
Moderator: DosItHelp
Re: Replacing Double Quotes using BatchSubstitute
Hi Steve,
I suppose something like this should work.
I suppose something like this should work.
Code: Select all
@echo off
set myVar=Text with "quotes"
set newVar=%myVar:"=#%
echo %newVar%
Re: Replacing Double Quotes using BatchSubstitute
I am trying to do something like this:
BatchSubstitute.bat """" "" filein.txt > fileout.txt
I have data similar to this:
"Red","Blue",1,2,3,"Green"
And, want those double-quotes to be replaced with empty strings, i.e.
Red,Blue,1,2,3,Green
The """" above doesn't seem to do anything. I have tried things like "\"\"", et al, with no luck.
Thanks,
Steve
BatchSubstitute.bat """" "" filein.txt > fileout.txt
I have data similar to this:
"Red","Blue",1,2,3,"Green"
And, want those double-quotes to be replaced with empty strings, i.e.
Red,Blue,1,2,3,Green
The """" above doesn't seem to do anything. I have tried things like "\"\"", et al, with no luck.
Thanks,
Steve
Re: Replacing Double Quotes using BatchSubstitute
In this case you should switch to JREPL.bat from dbenham.
It's much more powerful than BatchSubstitute.bat and can handle such cases
It's much more powerful than BatchSubstitute.bat and can handle such cases
Re: Replacing Double Quotes using BatchSubstitute
JREPL is the way to go...
But if you always knew how many delimited fields you were working with you could easily do it with a FOR /F command as long as none of the fields are empty.
But if you always knew how many delimited fields you were working with you could easily do it with a FOR /F command as long as none of the fields are empty.
Code: Select all
FOR /F "TOKENS=1-6 DELIM=," %%G IN (myfile.txt) DO >>newfile.txt ECHO %%~G,%%~H,%%~I,%%J,%%~K,%%~L
Re: Replacing Double Quotes using BatchSubstitute
Code: Select all
@echo off
set "in=filein.txt"
set "out=fileout.txt"
for /f %%i in ('^<"%in%" find/c /v ""') do<"%in%">"%out%" (
for /l %%j in (1 1 %%i) do (
set/p "x="
if defined x (cmd/v/c echo(!x:^"=!) else (echo()
set "x="
)
)
exit/b