I'm trying to use the command: "set n=0" "for /f %%i in ('dir /a:d /b') do (set /a n+= 1) & (set var%n%=%%i)" - It always sets %%i into var0, but i can see that "set n+= 1" is working. How can i use "n" to create a different variable for each turn?
Like: var1,var2,var3.. for each folder in the directory.
Regardless of the answer, i need 'n' to hold the number of times the command ran(so the program will know the amount of folders)(Edit: Yes i know my example provides this, i was meaning if anyone changed the code, that 'n' still needed to be set to the number of runs)
Edit: I have reviewed the page: Arrays, linked lists and other data structures in cmd.exe (batch) script And found it usefull, but i don't really understand the proper usage. Could someone please help me by either fixing my code to work with DelayedExpansion or better explaining how to implement it?
Edit: Guys! This i NOT a duplicate. I tried to use DelayedExpansion and couldn't get it to work. My problem was cause by my text editor i was using (NotePad++) that is why i thought i was using DelayedExpansion wrong and was asking for clarification. I ended up fixing it myself after the answer below proved that my code WAS correct.