A simple idea, by using two lines, as per my comment:
@FOR /L %%A IN (1,1,9) DO @MD 0%%A 2>NUL
@FOR /L %%A IN (10,1,20) DO @MD %%A 2>NUL
You can also do this in one line by not setting variables unnecessarily:
@FOR /L %%A IN (1,1,20) DO @IF %%A LSS 10 (MD 0%%A 2>NUL) ELSE MD %%A 2>NUL
Or you could set the variable before the loop:
@SET "J=0"
@FOR /L %%A IN (1,1,20) DO @IF %%A LSS 10 (MD "%J%%%A" 2>NUL) ELSE MD %%A 2>NUL
You could still set the variable in the loop and force expand it using Call
:
@FOR /L %%A IN (1,1,20) DO @IF %%A LSS 10 (SET "J=0" && CALL MD "%%J%%%%A" 2>NUL) ELSE MD %%A 2>NUL
Or expand it using delayed expansion:
@SETLOCAL ENABLEDELAYEDEXPANSION
@FOR /L %%A IN (1,1,20) DO @IF %%A LSS 10 (SET "J=0" && MD "!J!%%A" 2>NUL) ELSE MD %%A 2>NUL
And you could parse the results to remove the leading 1
:
@FOR /L %%A IN (101,1,120) DO @SET "VAR=%%A" && CALL MD "%%VAR:~-2%%" 2>NUL
Or using delayed expansion:
@SETLOCAL ENABLEDELAYEDEXPANSION
@FOR /L %%A IN (101,1,120) DO @SET "VAR=%%A" && MD !VAR:~-2! 2>NUL