Computing.Net > Forums > Programming > Reading a text file with a .bat

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Reading a text file with a .bat

Reply to Message Icon

Name: cmdrfred
Date: March 28, 2009 at 00:11:22 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

Here is what I want to do is it possible, I have a number of lists and they each have 50 lines, I want to set each line of this list as a variable.

so for example:
SET inv01 = line 1 from text file
SET inv02 = line 2 from text file
and so on up to 50.

The rest of the program works if I set the values up manually, I'm wondering if I can automate this process. Any Idea's Ive looked around but cant seem to find an answer to this.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: March 28, 2009 at 00:45:03 Pacific
Reply:

@echo off & setLocal EnableDelayedExpansion

set N=

for /f "tokens=* delims=" %%a in (myfile) do (
set /a N+=1
set var!N!=%%a
)

set v


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: cmdrfred
Date: March 28, 2009 at 05:13:06 Pacific
Reply:

Works perfect thanks alot :)


0

Response Number 3
Name: lee123abc
Date: March 28, 2009 at 08:36:47 Pacific
Reply:

M2 - Why the 'set v' ?


0

Response Number 4
Name: Mechanix2Go
Date: March 29, 2009 at 00:03:00 Pacific
Reply:

lee, just to 'show what was done'


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Reading a text file with a .bat

Editing a Text File With a Batch www.computing.net/answers/programming/editing-a-text-file-with-a-batch/14889.html

I need a .bat file! www.computing.net/answers/programming/i-need-a-bat-file/16333.html

editing text file with a batch file www.computing.net/answers/programming/editing-text-file-with-a-batch-file/16828.html