How can I access an element from a list/array in a windows batch code? -


@echo off set counter=0 set folders=(14370437 14707356 16048938 16818856)  %%f in (*.jpg) call :p "%%f"  goto :eof  :p     set /a counter+=1     set /a x=counter %% 6      %name% = folders[counter] ???      mkdir c:\output\%name%     if %x%==1 copy %1 c:\output\%name%\front-image.jpg goto :eof 

i have static list of folder names (the list longer example) , function need use them. loop through bunch of .jpg files , need copy each 1 next folder in list (also create folder)

i couldn't find way retrieve element list (or array?) folders, index.

batch can't work lists or arrays, can simulate array:

@echo off setlocal enabledelayedexpansion set folders=(14370437 14707356 16048938 16818856) set i=0 %%i in %folders% (   set /a i+=1   set element[!i!]=%%i ) set element echo %element[2]% 

although works, suggest, using parantheses belong:

@echo off setlocal enabledelayedexpansion set folders=14370437 14707356 16048938 16818856 set i=0 %%i in (%folders%) (   set /a i+=1   set element[!i!]=%%i ) set element echo %element[2]%  set number=3 echo !element[%number%]! 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -