@echo off
set Counter=0
set folders=(14370437 14707356 16048938 16818856)
for %%f in (*.jpg) do 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 a static list of folder names (the list is much longer than this example) and another function where I need to use them. I loop through a bunch of .jpg files and need to copy each one to the next folder in the list (also create the folder)
I couldn't find a way to retrieve an element from the list (or array?) folders, by index.
batch can't work with lists or arrays, but you can simulate an array:
@echo off
setlocal enabledelayedexpansion
set folders=(14370437 14707356 16048938 16818856)
set i=0
for %%i in %folders% do (
set /a i+=1
set element[!i!]=%%i
)
set element
echo %element[2]%
Although this works, I strongly suggest, using the parantheses where they really belong:
@echo off
setlocal enabledelayedexpansion
set folders=14370437 14707356 16048938 16818856
set i=0
for %%i in (%folders%) do (
set /a i+=1
set element[!i!]=%%i
)
set element
echo %element[2]%
set number=3
echo !element[%number%]!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With