Batch- Setting a line in a .txt as a variable

September 6, 2010 at 09:15:36
Specs: Windows XP
I'm trying to write a .bat file that will take a text file with a crap load of lines in it,
and turn every line into a variable.
I got stuck right here:

setLocal EnableDelayedExpansion
set /a N=0
for /f "tokens=* delims= " %%a in (ms.txt) do (
set /a N+=1
set m!N!=%%a
set dir=%cd%
set mes!N!= What do I put here?

I need it so that each variable starts with "mes" and ends with the line number, which I have already done.
However, I can't figure out how to put the contents of the line in each variable.
I need to put "m(line number here)" in them.
I've tried things like !!m!N!!!, %m!N!%, and !m%N%!, but it either displays only the line number or
the letter N.

See More: Batch- Setting a line in a .txt as a variable

Report •

September 6, 2010 at 09:31:22
Making two identical pseudo arrays from a file seems to be redundant, if you really want "mes!n!" to be identical to "m!n!" then you may as well set it to %%a.

Report •

September 6, 2010 at 09:49:12
Oh wow, didn't think about that. I feel stupid now.

Thanks. :P

Report •

Related Solutions

Ask Question