0

I'm writting a script in Windows, a .BAT file, to replace:

"""2014

With:

"""14

But I'm havng problems with de double quote character. This is how the script looks like:

@echo off
setlocal enabledelayedexpansion
set INTEXTFILE=FILE_IN_CSV.csv
set OUTTEXTFILE=222.csv
set SEARCHTEXT=^"^"^"2014
set REPLACETEXT=^"^"^"4
set OUTPUTLINE=

for /f "tokens=1,* delims=¶" %%A in ( '"type %INTEXTFILE%"') do (
SET string=%%A
SET modified=!string:%SEARCHTEXT%=%REPLACETEXT%!

echo !modified! >> %OUTTEXTFILE%
)
del %INTEXTFILE%
rename %OUTTEXTFILE% %INTEXTFILE%

Any ideas?

EDIT:

Now I see the problem. What I need to replace is not:

"""2014

Actually is this:

""
"2014

Note that there is an ENTER, I mean the string is in two lines.

EDIT2:

Looks more complicated now: after de 2 double quotes there are 2 blank spaces and then de "ENTER"

""
"2014

So, something like: (doublequotes)(doublequotes)(blanck_space)(blanck_space)(new_line)(doublequotes)2014

Thanks!

user3139207
  • 121
  • 13
  • 2
    What is your problem? The code appears to work for me, other than your replacement string has 4 instead of 14. – dbenham Oct 07 '14 at 17:54
  • The string to replace was incorrect, tehre is an "ENTER" between the first double quotes character and the others double quotes. – user3139207 Oct 08 '14 at 09:30
  • So you try to find and replace a multiline string while reading the file line by line? – jeb Oct 08 '14 at 12:20
  • Duplicate of [BAT file to replace string in two lines](http://stackoverflow.com/questions/26288377/bat-file-to-replace-string-in-two-lines) by same questioner. – Mofi Oct 10 '14 at 22:43

0 Answers0