批处理变量应用方法
作者:
批处理变量应用方法
详细帮助参考:set /? cmd /? 务必仔细看!
具体应用:
1、获取变量子字符串:echo %date:~0,4%%date:~5,2%%date:~-2,2%%time:~0,2%%time:~3,2%%time:~6,2%
2、变量内容替换: set str=000111000 && echo %str:000=222% && echo %date:-=%%time::=%
3、延迟变量环境扩展:cmd /v:on
set /a j=0
for /l %i in (1,1,10) do set /a j=!j!+%i
具体应用:
1、获取变量子字符串:echo %date:~0,4%%date:~5,2%%date:~-2,2%%time:~0,2%%time:~3,2%%time:~6,2%
2、变量内容替换: set str=000111000 && echo %str:000=222% && echo %date:-=%%time::=%
3、延迟变量环境扩展:cmd /v:on
set /a j=0
for /l %i in (1,1,10) do set /a j=!j!+%i