Help for loop replace string
Posted: 02 Jun 2019 02:19
This is my test.tmp file
This is my copy.bat file
Output is
Problem is the line ECHO is off. It must not appear, how can I solve it? Please help me out of this trouble.
Code: Select all
TEMPLATE = Test
Test = \
Test1 \
Test2
Code: Select all
@echo off
set oldText1=Test1 \
set oldText2=Test2
set newText1=newTest
set newText2=
setlocal enableDelayedExpansion
for /F "tokens=1* delims=]" %%j in ('type "Test.tmp" ^| find /V /N ""') do (
if "%%k"=="" (
echo.
) else (
set "line=%%k"
set "line=!line:%oldText1%=%newText1%!"
set "line=!line:%oldText2%=%newText2%!"
if not !line!==[] echo !line!
)
)
endlocal
Code: Select all
TEMPLATE = Test
Test = \
newTest
ECHO is off.