Windows 如何访问for循环中的变量
我正在试验for循环,到目前为止已经有了这个-Windows 如何访问for循环中的变量,windows,batch-file,cmd,Windows,Batch File,Cmd,我正在试验for循环,到目前为止已经有了这个- echo off set "projectPath=%~1\Translations\" echo projectPath %projectPath% cd %projectPath% set "tmp=f" for /r %%g in (*.ts) do ( echo %%g set %tmp%="www" echo %tmp% ) 当运行tmp为“f”时,我不知道为什么 有人能解释一下发生了什么事吗 echo p
echo off
set "projectPath=%~1\Translations\"
echo projectPath %projectPath%
cd %projectPath%
set "tmp=f"
for /r %%g in (*.ts) do (
echo %%g
set %tmp%="www"
echo %tmp%
)
当运行tmp为“f”时,我不知道为什么
有人能解释一下发生了什么事吗
echo projectPath %projectPath%
cd %projectPath%
setlocal enableDelayedExpansion
set "tmp=f"
for /r %%g in (*.ts) do (
echo %%g
set %tmp%="www"
echo !tmp!
)
endlocal
延迟扩展是与批处理脚本相关的最令人困惑的事情之一。有关更多信息,请查看下面的链接