In Windows CMD batch loop I would like to use dynamic variables: list1, list2 and list3 where the digit 1-3 is dynamic (ie: list&i), but I am struggling:
setlocal enabledelayedexpansion enableextensions
SET threads=3
set i=1
for /R %%x in (*.jpg) do ( call set LISTNAME=LIST!i! & SET LIST!i!=!LISTNAME! "%%x" & set /A i=!i!+1 & if !i! gtr %threads% (set i=1))
echo "first" %LIST1%
echo "second" %LIST2%
echo "third" %LIST3%
The exact spot where I struggle is:
SET LIST!i!=!LISTNAME! "%%x"
where I would like this for instance to be:
SET LIST1=!LIST1! "%%x"
However listname just translates to a string LIST1, never the variable LIST1. I also tried with no success:
SET LIST!i!=!LIST!i!! "%%x"
Purpose of the script: put the JPG file names in 3 lists EDIT to answer to first comment: files names distributed in round robin and separated with a space.