The following nested for-loop drives me mad (on Windows 7):
@echo off
SetLocal EnableDelayedExpansion
set TESTDIRS=fast mid slow
set TD=src\\test\\resources
Because nobody has mentioned it, here is the solution using batch subroutines and the CALL
command.
@echo off
set TESTDIRS=fast mid slow
set TD=src\test\resources\testsuite
for %%d in (%TESTDIRS%) do call :process_testdir %%d
goto :eof
:process_testdir
set CTD=%TD%\%1
echo CTD: %CTD%
REM Echos the expected path
for /R %CTD% %%f in (*.fs) do (echo %%f)
REM Echos as expected
goto :eof
I know GOTO is not very popular, but batch files were originally designed to use labels for control flow. The parenthetized control structure syntax was added later, and this question is an example of where it breaks down. The problem lends itself well to batch subroutines.