If you have a variable inside this for /f
command, it doesn't get printed out to file.
setlocal EnableDelayedExpansion
for /F %%i in ('dir /B') do (
set duration=asdf
echo %duration% > file.txt
)
Contents of file.txt
: Echo is ON.
If you move set duration=asdf
out of for /f
wrap and put it below setlocal
line it works correct and prints asdf
into file.txt
Why? How do I do this with the set variable inside the for
command?