批脚本1(用call不用变量延迟失败):
@echo off
for /f "delims=*" %%a in (d:\test.txt) do (
set var=%%a
set var=%var:11=6%
call echo %%var%% >>testok.txt
)
pause
执行后d:\testok.txt的内容为
11=6
11=6
11=6
11=6
批脚本2(启用变量延迟能实现目的):
@echo off
for /f "delims=*" %%a in (d:\test.txt) do (
setlocal enabledelayedexpansion
set var=%%a
set var=!var:11=6!
@echo !var! >>testok.txt
)
pause