DOS batch file help
#1
Scooby Regular
Thread Starter
I need to figure out a way of reading each line of a simlpe text file and for each of them it needs to be passed to a command as a paramter.
For example, if I create a file called MACHINES.TXT. This file contains the following:-
PDC
BDC
MAIL
WEB
I then want to read each line and pass this to an ECHO command. I've been looking at the FOR command, but can't figure out how to tell it to use the input file and read each line.
Stefan
For example, if I create a file called MACHINES.TXT. This file contains the following:-
PDC
BDC
WEB
I then want to read each line and pass this to an ECHO command. I've been looking at the FOR command, but can't figure out how to tell it to use the input file and read each line.
Stefan
#2
What operating system? As long as it's not real DOS or W9x then this will work on NT, W2K and XP
FOR /F %%Z IN (MACHINES.TXT) DO @ECHO %%Z
Assumes your file has only one word per line otherwise you'll have to add options to the command to change the default delimeters from spaces.
FOR /F %%Z IN (MACHINES.TXT) DO @ECHO %%Z
Assumes your file has only one word per line otherwise you'll have to add options to the command to change the default delimeters from spaces.
Thread
Thread Starter
Forum
Replies
Last Post