以下嵌套for循环驱使我疯狂(在Windows 7上):
- @echo off
- SetLocal EnableDelayedExpansion
- set TESTDIRS=fast mid slow
- set TD=src\test\resources\testsuite
- for %%d in (%TESTDIRS%) do (
- set CTD=%TD%\%%d
- echo CTD: !CTD!
- REM Echos the expected path
- echo CTD: %CTD%
- REM Echos nothing -- understandable
- for /R !CTD! %%f in (*.fs) do (echo %%f)
- REM Echos nothing -- why?
- for /R src\test\resources\testsuite\fast %%f in (*.fs) do (echo %%f)
- REM Echos expected files
- )
我尝试了各种解决方案,包括禁用DelayedExpansion,调用语句和whatnot,但我从来没有内部循环工作。我知道我可以通过一个子程序调用来替换内部循环,但是必须有一种方法来使其与嵌套循环一起使用。
如果你用pushd!CTD怎么办?和popd,并让FOR / R默认使用当前目录?