我试图在Delayed Variable Expansion中使用动态变量来表示其他动态变量。我遇到了一些麻烦。如果动态变量的值是具有自己的值的另一个动态变量,如何获得动态变量的值?批处理中递归动态变量的返回值
即!valA! =%valB%=这
@ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion
...
...
FOR /F ... %%G IN (...) DO (
SET _temp=%%~nG
SET _file=!_temp:~0,-4!
SET _cnt=0
FOR /F ... %%L IN (...) DO (
SET _temp=%%L
SET _str=!_temp:*: =!
SET /A _cnt+=1
SET _temp=x!_file!!_cnt!
IF DEFINED !_temp! (
SET _temp=!%_temp%!
::
::_temp('s value) is _var('s value) is "xyz"
::Set new _temp to equal current _temp's "xyz"
::
IF !_temp! NEQ !_str! (
ECHO File Content Mismatch
)
) ELSE (
SET xvar=!_temp!
SET !xvar!=!_str!
)
)
)
...
...
exit
任何帮助,将不胜感激。
Woot!博士学位批处理脚本。我认为每个人都已经起来,最近用PowerShell去了 – sehe
我很好奇这行:“SET _temp =!%_ temp%!”。你能解释你想做什么吗? – Arun
@Arun将_temp重新赋给当前的_temp(这是一个变量名)值。 – seantmanley