This is my first answer ever on here so we shall see how it goes.
I did some research and didn't find anything specifically for shuffling inputs to a for command, but I did find that you could store your inputs in a batch array and do some shuffling with that. However, this does mean that a for command isn't used.
Here is the code that I used to produce the shuffled array:
@echo off
setlocal enabledelayedexpansion
set inputVars[0]=1
set inputVars[1]=2
set inputVars[2]=3
set inputVars[3]=4
set inputVars[4]=5
set /A inputsLength=0
:lengthLoop
if defined inputVars[%inputsLength%] (
set /A inputsLength+=1
goto :lengthLoop
)
set /A currentIndex=0
:loop
set /A randIndex=%RANDOM% %%%inputsLength%
set temp=!inputVars[%currentIndex%]!
set inputVars[%currentIndex%]=!inputVars[%randIndex%]!
set inputVars[%randIndex%]=%temp%
set /A currentIndex+=1
if currentIndex LSS %inputsLength% (
goto :loop
)
set /A currentIndex=0
:outputLoop
if defined inputVars[%currentIndex%] (
echo !inputVars[%currentIndex%]!
set /A currentIndex+=1
goto :outputLoop
)
endlocal
The first bit of code after the array initialization finds the length of the array for convenience. The length may seem obvious, but I'm not sure how exactly you'd be getting your inputs or populating the array so I went ahead and added it.
set /A inputsLength=0
:lengthLoop
if defined inputVars[%inputsLength%] (
set /A inputsLength+=1
goto :lengthLoop
)
The second bit actually does the shuffling by using %RANDOM%. I used this question as a reference for that.
set /A currentIndex=0
:loop
set /A randIndex=%RANDOM% %%%inputsLength%
set temp=!inputVars[%currentIndex%]!
set inputVars[%currentIndex%]=!inputVars[%randIndex%]!
set inputVars[%randIndex%]=%temp%
set /A currentIndex+=1
if currentIndex LSS %inputsLength% (
goto :loop
)
The last bit of the code actually iterates over the array, so that's where the for command was replaced in order to make this work.
set /A currentIndex=0
:outputLoop
if defined inputVars[%currentIndex%] (
echo !inputVars[%currentIndex%]!
set /A currentIndex+=1
goto :outputLoop
)
I hope this helped or at least got you thinking about possible ways of implementing what you have in mind.