Command language supports creation array. For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | @echo off
setlocal enabledelayedexpansion
::incremental varibale
set "i=0"
::store filenames into array
for /f "tokens=*" %%f in ('dir /b') do (
set arr[!i!]=%%f & set /a "i+=1"
)
::display all array items
set arr
::just line
echo.===================================
::print array items (from 0 till n)
set "len=!i!"
set "i=0"
:loop
echo !arr[%i%]! & set /a "i+=1"
if %i% neq %len% goto:loop
endlocal
::another way to create array arr.!i!=%%f
exit /b
|
Tags: array