I have a very weird error occurring in my Batch script where a For loop is only looping once when it should loop many more times (at least 10 times).
Can you tell me why my For loop is only looping once and how I can fix it?
@ECHO off
CLS
SETLOCAL
SET macroFolder=_PLACE_4DM_FILES_HERE
REM the following for loop only loops once when it should be looping more
REM because theres over 10 *.4dm files in the folder??
for /r ./%macroFolder% %%i in ("*.4dm") do SET "file=%%i" (
echo %file%
REM Note I need to store %%i in a variable so I can edit it later
REM And placing %%i in a variable within the for loop results in
REM the var being empty for some reason. For eg
SET file=%%i
ECHO file is %file%
REM Prints "file is "
)
ECHO.
PAUSE
ENDLOCAL
for /r "./%macroFolder%" %%i in ("*.4dm") do echo(%%i*.4dm?./%macroFolder%form is exactly the same than just%macroFolder%, that is, %macroFolder% folder in current directory, and usually never used!