Lists mapping and scanning in Batch -


i know batch poor scripting language , can't expect think done, yet don't know if there easier ways. want loop through 2 list of elements (the same number), connected between them associative array. want keep reference of position of item in first list , item second list. maybe code explain better:

set projects=(project1 project2 project3) set files=(project1.txt project2.txt project3.txt)  %%i in %projects% (     :: corresponding value in files set projectfile=projects[%%i] ) 

for project1 want project1.txt, project2 want project2.txt , on. there trick or harder way achieve this?

you can use pseudo arrays here.

first files assigned pseudo array file[0]..file[2].
each project number associated file fetched.

@echo off setlocal enabledelayedexpansion set projects=project1 project2 project3 set files=project1.txt project2.txt project3.txt  set /a file_n=0 %%f in (%files%) (     set /a file_n+=1     set "files[!file_n!]=%%f" )  set proj=0 %%p in (%projects%) (     set /a proj+=1     call set file=%%files[!proj!]%%     echo !file! ) 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -