我的批处理文件中有一个数组,如下所示:
"port[0] ="
"port[1] = 0"
"port[2] = 3"
"port[3] = 2"
是否有任何漂亮而优雅的方法可以将值向后移动一个元素,所以它看起来像这样?:
"port[0] = 0"
"port[1] = 3"
"port[2] = 2"
"port[3] ="
我想要的不仅仅是SET port[0] = %port[1]%
, etc?
:: Q:\Test\2018\11\23\SO_53453204.cmd
@Echo off&SetLocal EnableDelayedExpansion
set "port[0]=" &Rem this clears/deletes the variable
set "port[1]=0"
set "port[2]=3"
set "port[3]=2"
For /L %%L in (1,1,3) do (
set /A "New=%%L-1,Last=%%L"
set "port[!New!]=!port[%%L]!"
)
:: finally reset the last entry
set "port[%Last%]="
set port[
> Q:\Test\2018\11\23\SO_53453204.cmd
port[0]=0
port[1]=3
port[2]=2
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)