我的批处理文件中有一个数组,如下所示:
"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]%
等等?
:: 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
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句