I have a for loop in a batch file. I get this weird behaviour with the counter variable. I am an experienced programmer, but a beginner in batch files.
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SET list=test1 test2 test3
FOR %%a IN (%list%) DO (
SET variable=%%a
ECHO %%a
ECHO -%variable%-
)
I expect the output to be
test1
-test1-
test2
-test2-
test3
-test3-
but it actually is
test1
-test3-
test2
-test3-
test3
-test3-
What am I doing wrong?