Code: Select all
@echo off
setlocal enabledelayedexpansion
set INTEXTFILE=file.txt
set OUTTEXTFILE=new.txt
set SEARCHTEXT=Target = TESTCore/TEST.exe
set REPLACETEXT=Target =TEST.exe
set OUTPUTLINE=
for /f "tokens=1,* delims=¶" %%A in ( '"findstr /n ^^ %INTEXTFILE%"') do (
SET string=%%A
for /f "delims=: tokens=1,*" %%a in ("!string!") do set "string=%%b"
if "!string!" == "" (
echo.>>%OUTTEXTFILE%
) else (
SET modified=!string:%SEARCHTEXT%=%REPLACETEXT%!
echo !modified! >> %OUTTEXTFILE%
)
)
::del %INTEXTFILE%
rename %OUTTEXTFILE% %INTEXTFILE%
As everyone see - it suppose to find and replace string in txt file.
The problem is that i get incorrect replacement when i start to use = symbol.
So instead of this output.
Code: Select all
Target = TEST.exe
I get something like this:
Code: Select all
TESTCore/TEST.exe=Target = TEST.exe= TESTCore/TEST.exe
I have no idea how to solve it, i tried many hours to do that.
Hope someone can help me, i will attach files that i use if anyone need it to make al this thng more clear.