# Reading From txt to batch



## Greengiant224 (Nov 22, 2010)

Hi,

I have a problem with reading a text file into a batch file. 
Looking through this forum for answers came up with the solution to read from a single line and put into variables. This I have got working. My problem is, I would like to read the separate 
lines (in the text file) and assign them each to a new variable to use further along in the batch. Can this be done?

The text file is set out thus:

:: Enter items one per line
apples
oranges
bananas
grapes
lemons

Thanks in advance for your answers


----------



## Squashman (Apr 4, 2003)

Well if you are using a For Loop to parse the text file and you need them into separate variables then create a pseudo array.
Put a counter in the for loop and use the counter as part of the variable name.


----------

