for /r command cannot accept a variable for the "c:\path" portion in for /r "c:\path" %%a in (*) do when it is within a loop.
Consider this example: you must have folders with a tree of files inside them, in the current directory.
Nothing is echoed.
Code: Select all
@echo off
for /d %%a in (*) do (
for /r "%%a" %%b in (*) do echo "%%b"
)
I've tried it with an environment variable that is set before the loop starts, and that works ok
but using delayed expansion is not a solution either as it doesn't change the result: see below
Code: Select all
@echo off
setlocal enabledelayedexpansion
for /d %%a in (*) do (
set "folder=%cd%"
for /r "!folder!" %%b in (*) do echo "%%b"
)
The issue doesn't really need parentheses as this fails too.
Code: Select all
@echo off
for /d %%a in (*) do for /r "%%a" %%b in (*) do echo "%%b"
So the expected syntax would have to change for this to work.
foxi