I have a text file like this
myFile.txt:
apple
banana
grapes
I want to drag text file to batch file and set variables into an array like this:
array[0]=apple
array[1]=banana
array[2]=grapes
But i couldn't do that. My problem is not just printing them but i can't even do that. I'll do parse operations at the rest of batch file. My Code:
@echo off
setlocal EnableDelayedExpansion
set i=0
for /f %%a in %1 do (
set /a i+=1
set array[!i!]=!a!
)
echo %array[0]%
echo %array[1]%
echo %array[2]%
endlocal