Hi,
I am trying to come up with a batch file that will find and replace text in a text file. So far I am using this:
to edit myfile.txt:
However, when using the syntax:
echo %Text%>> c:\newfile.txt
I am not obtaining the correct text. I get:
instead of:
Can someone explain what is incorrect and how to solve it?
Much appreciated,
Skippybox
I am trying to come up with a batch file that will find and replace text in a text file. So far I am using this:
Code:
@echo off if exist c:\newfile.txt del c:\newfile.txt for /f "tokens=*" %%a in (c:\myfile.txt) do call :Change "%%a" del c:\myfile.txt rename c:\newfile.txt myfile.txt exit /b :Change set Text=%~1 if "%Text%"=="VarC=100" ( echo VarC=200>> c:\newfile.txt ) else ( echo %Text%>> c:\newfile.txt ) exit /b
Code:
[setup] VarA=1 VarB=10 VarC=100 VarD=0
echo %Text%>> c:\newfile.txt
I am not obtaining the correct text. I get:
Code:
[setup] VarA= VarB=10 VarC=200
Code:
[setup] VarA=1 VarB=10 VarC=200 VarD=0
Much appreciated,
Skippybox
Comment