我正在尝试遍历每个目录并为powershell脚本构建一个命令,稍后我会执行该命令。
@echo off
del c:\temp\Pack*.log
FOR /d %%d in (C:\dev\BlubDev\Releases\*.*) DO (
set fullDir=%%d
set dirName=%fullDir:~24,100%
set tempLog=c:\temp\Pack%dirName%.log
set myvar=%%d\Tools\Build\BlubCreatePackageOnCentral.ps1
ECHO %myvar% ^> %tempLog%
)
但为什么打印总是相同(也许是最后找到的)dir?
答案 0 :(得分:3)
@echo off
del c:\temp\Pack*.log
setlocal enableDelayedExpansion
FOR /d %%d in (C:\dev\BlubDev\Releases\*.*) DO (
set fullDir=%%d
set dirName=!fullDir:~24,100!
set tempLog=c:\temp\Pack!dirName!.log
set myvar=%%d\Tools\Build\BlubCreatePackageOnCentral.ps1
ECHO !myvar! ^> !tempLog!
)