In batch files, replacing certain text in file a.txt with other text
for /f "tokens=* delims= " %%i in (a.txt) do (
set n=%%i
set n=!n:aaa=bbb!
echo !n! | find /I "ECHO"
IF ERRORLEVEL 1 (
echo !n! >> temp.txt
) else (
echo. >>temp.txt
)
)
copy temp.txt a.txt
If the string aaa contains spaces or dots ., it cannot be replaced correctly. Is there any expert who has a better solution? Thanks thanks thanks...
for /f "tokens=* delims= " %%i in (a.txt) do (
set n=%%i
set n=!n:aaa=bbb!
echo !n! | find /I "ECHO"
IF ERRORLEVEL 1 (
echo !n! >> temp.txt
) else (
echo. >>temp.txt
)
)
copy temp.txt a.txt
If the string aaa contains spaces or dots ., it cannot be replaced correctly. Is there any expert who has a better solution? Thanks thanks thanks...

