replacing text in file with an equal-sign in it
Posted: 04 Jul 2013 08:08
Hi,
I think I´ve a simple problem, but can´t find out the solution.
I read a text-file line by line and want to replace some text.
That´s no problem so far, but the text to be replaced has an equal-sign (=) in it.
I don´t find out, how to mask this sign.
For better understanding, here my code:
many thanks for help!
I think I´ve a simple problem, but can´t find out the solution.
I read a text-file line by line and want to replace some text.
That´s no problem so far, but the text to be replaced has an equal-sign (=) in it.
I don´t find out, how to mask this sign.
For better understanding, here my code:
Code: Select all
@echo off
setlocal enabledelayedexpansion
set sourcefile="C:\filename_BACKUP.ini"
set targetfile="C:\filename.ini"
set pattern="=prod/in"
set replace="=/prod/in"
rename C:\filename.ini filename_BACKUP.ini
if exist %targetfile% (del /f %targetfile% 1>NUL 2>NUL)
for /F "delims=" %%a in ('findstr . "%sourcefile%"') do (
set text=%%a
set text=!text:%pattern%=%replace%!
echo !text!>>%targetfile%
)
many thanks for help!