我試圖在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