# Read Values from Text file line-by-line and Use a Single Variable



## TheChadWork2001 (Mar 21, 2012)

I have a file called c:\text.txt with the following two lines in it: One Two I want my batch to read the first value, set a single variable equal to it, and then process some commands on that variable, and then read the next line and do the same thing. I tried this: for /F &quot;tokens=*&quot; %%A in c:\text.txt do ( echo A is: %%A set VARTEMP=%%A echo VARTEMP is: %VARTEMP% ) What I expect to see is this: A is: One Vartemp is: One A is: Two Vartemp is: Two But what happens is: A is: One Vartemp is: Two A is: Two Vartemp is: Two Vartemp is always equal to the last line in the file. Please help! THanks!


----------



## TheChadWork2001 (Mar 21, 2012)

Sorry, I don't know what's wrong with the formatting of this forum.


----------



## Squashman (Apr 4, 2003)

Use bulletin board code tags around your input examples and the code you are using and also what you expect the output to be.
I can't really decipher what is what which is making it difficult to determine what you are trying to do.


----------

