I have a loop that enumerates all arguments.
From this loop I want to loop thought all up until the current argument.
@ECHO OFF
setlocal enabledelayedexpansion
SET /a Counter=0
FOR %%a IN (%*) DO (
SET /a Counter=!Counter!+1
FOR /L %%A IN (1, 1, !Counter!) DO (
ECHO %%%%A
)
)
I have tried %%!A! and various combinations of % and !. I have also tried to first add a variable to a inner loop and tried using that.
The closest I get is to get literal values for example %1 %2 %3
Sample execution for arguments TEST1 TEST2 TEST3 should be
TEST1 (from outer loop)
TEST1 (from inner loop)
TEST2 (from outer loop)
TEST1 (from inner loop)
TEST2 (from inner loop)
TEST3 (from outer loop)
TEST1 (from inner loop)
TEST2 (from inner loop)
TEST3 (from inner loop)
I see multiple approaches when using a single loop but not any with nested loops
shift
to contextually change the value of%1
to another arguments value incrementally. ss64.com/nt/shift.html see this SO thread for an example: stackoverflow.com/questions/935609/…shift
does not affect%*
, so your outter loop should not be affected by the operation, as I'm reading your script. Per the ss64.com link above "SHIFT will not affect the value of %* which holds all the original arguments %1 %2 %3..."