从replace.bat两个批处理文件目前的运行情况看,
setlocal enabledelayedexpansion 是非常重要的。
否者,在循环语句中的替换变量是不能发挥应有作用的。
同时,值得一提的是,这个语句最好放在循环语句内部,以保证运行过程不出现问题。
另外,是关于“%%”和“!!”两个符号所代替的变量有所不同,在循环语句内部
strrpc中,%%是没有作用的。然而,!!却工作的很好。对此的区别,我还不是很明了。
但是,在set /a 中,两者却是一样的。
Program name: Replace.bat
for /L %%a in (1,10,30) do (
copy test.txt test%%a.txt/y
setlocal enabledelayedexpansion
set /a bb=%%a+10
pause
echo !bb!
pause
strrpc yangjun !bb! /s:test%%a.txt /c:
if errorlevel 1 pause
)
Note: If you write the Echo %bb%, the value will not appear on the screen. However, the form of !bb! works well.
评论