Massive fill array in a loop

Hi, I have a big problem in the package, its complexity is to tell, but I understood how to solve it, the problem is that I did not know how to do this in batch mode, if in C # I can do it easily since im new in the party, below C #, can you guys teach me how to do the same in batch? i google'd all day but can't find a way, thanks in advance

ArrayList list = new ArrayList(); //let say variable "Filesx" consist of files count in one folder for(int i = 0; i < Filesx; i++){ list.Add("file number : " + i); } 

P / S: if arraylist is not possible in batch mode, only the array is approved

+4
source share
1 answer
 @echo off setlocal EnableDelayedExpansion rem Populate the array with existent files in folder set i=0 for %%a in (*.*) do ( set /A i+=1 set list[!i!]=%%a ) set Filesx=%i% rem Display array elements for /L %%i in (1,1,%Filesx%) do echo file number %%i: "!list[%%i]!" 

You should note that for convenience, indexes in batch processing arrays should start at 1, not 0.

For a detailed description of managing arrays in batch files, see Arrays, linked lists, and other data structures in the cmd.exe (batch) script

+4
source

Source: https://habr.com/ru/post/1492201/


All Articles