-2

Is there any way to set dyanamically index of array in batch script. please check my script bellow.

@echo off

SET /A i = 0
echo %i%   
set fileList[%i%]="1.txt"

Set /A i+=1
echo %i%
set fileList[%i%]="2.txt"

Set /A i+=1
echo %i%
set fileList[%i%]="3.txt"
vonPryz
  • 22,996
  • 7
  • 54
  • 65
Pritam Ajmire
  • 47
  • 1
  • 4
  • 1
    `FOR /L %%G IN (1,1,3) DO set "fileList[%%G]=%%G.txt"` – Squashman Mar 25 '20 at 13:53
  • 1
    Does this answer your question? [Arrays, linked lists and other data structures in cmd.exe (batch) script](https://stackoverflow.com/questions/10166386/arrays-linked-lists-and-other-data-structures-in-cmd-exe-batch-script) – T3RR0R Mar 25 '20 at 15:13

1 Answers1

0

I wanted to set index of array dynamically as mentioned in question & to check if it sets a incremented value for variable i & printed its index.

This code is absolutely fine, when I looped through the array I see all values set at its index, however echo %i% does not show actual value.

Anyway it is resolved now. Thanks for your help.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Pritam Ajmire
  • 47
  • 1
  • 4