@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
Diff to Previous Revision
--- revision 1 2012-11-01 18:26:16
+++ revision 2 2012-11-01 18:35:05
@@ -10,12 +10,12 @@
set arr
::just line
echo.===================================
- ::print array items in correct following
+ ::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**.
+ ::another way to create array arr.!i!=%%f
exit /b