I'll boil my overall problem down to a very simple question. How do I assign a variable within a for loop within a batch file?
If I use the following batch file in windows:
for %%f in (.\Update\!dos\*.zip) do (
echo %%f
set FileName3=%%f
echo %FileName3%
pause
)
It will echo the proper value for %%f but it echoes nothing for %FileName3%
I then tested it by directly assigning FileName3 a direct value like test, which failed.
In searching for solutions, a common pointer is to use is SETLOCAL enabledelayedexpansion
However, if I add that to the top of my batch file, it simply stops running. So while I think this is likely part of the solution, without the ability to run the batch file to test, I can't determine.
To be clear, with SETLOCAL enabledelayedexpansion at the top of my batch file, if I double click the file nothing happens. If I run it from a command line, it just goes back to the prompt as though nothing happened.
So my question is, how can I assign a variable within a loop in a batch file? If the answer is to use SETLOCAL enabledelayedexpansion, then why is adding that to my batch file causing it to do absolutely nothing.