This Batch file code snippet
@ECHO OFF
FOR %%i IN (1 2 3) DO (
ECHO %%i "%%i" %%a "%%a"
FOR /F "skip=%%i" %%j IN ("abc"
"abc"
"abc") DO ( ECHO. )
)
produces
1 "1" %a "%a"
%i" was unexpected at this time.
2 "2" %a "%a"
%i" was unexpected at this time.
3 "3" %a "%a"
%i" was unexpected at this time.
%%i is expanded properly (to 1,2,3) on the third line. However, on the fourth line %%i seems to expand to just %i. Apparently, the interpreter does not recognize on the forth line %%i as something that needs to be expanded and rather treats %% as the usual escape sequence for % and i just as i. Why does it happen? Is it just a bug (the interpreter is just implemented this way) or there is some logic in this behavior? if so, is it mentioned somewhere in the documentation?