I wrote this code:
set list1=This,Is,A,List
set list2=
FOR %%c IN (%list1%) DO set list2=%list2%-%%c
I expected list2 to equal -This-Is-A-List, instead it equals -List. I have verified that it is not "remembering" the value from the last iteration of the loop. I also tried this code:
setx list1 This,Is,A,List
setx list2 ""
FOR %%c IN (%list1%) DO setx list2 %list2%-%%c
And got much the same result. Is there a way to set an environment variable in a command FOR such that it will accumulate while the FOR is iterating?