I have a batch file which initializes variables via SET inside a for loop, for a set of files on disk:
for %%f in (%MYTARGETDIR%\*config.xml) do (
SET TMPFILE=%%F.tmp
echo In loop %TMPFILE%
)
echo End loop %TMPFILE%
when I run this in a brand new command shell (without TMPFILE defined) the In loop echo is empty, but the end loop echo is not.
When I run a second time, its already set, and outputs its value, ignoring the set until the loop closes.
Ideas why this is, and what the workaround is?