Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: capture a line at a time from a txt file  (Read 3281 times)

0 Members and 1 Guest are viewing this topic.

marco

  • Guest
capture a line at a time from a txt file
« on: April 06, 2004, 09:43:23 PM »
does anyone know how to capture a line of a text file from DOS

example text file:

marco
paul
linda


I'm looking to read the first line then set it equal to a variable in my batch file then read the next line in the second loop etc....

Tom Boykin

  • Guest
Re: capture a line at a time from a txt file
« Reply #1 on: April 07, 2004, 08:14:36 AM »
The answer would depend on the operating system you are talking about.  The following line will display each line in a text file (called sample.txt) if running a DOS window under Windows 2000 (all on one line):

for /f "tokens=1, 3* delims=~" %G IN (sample.txt) DO @ echo %G%H%I

If the preceeding command is run in a batch file, the references to variables %G, %H, %I would be %%G, %%H, %%I.

This command is not available in MSDOS 3-6.