Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

DOS batch file help

Thread Tools
 
Search this Thread
 
Old 27 August 2003, 10:32 AM
  #1  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
Question

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
Old 27 August 2003, 11:20 PM
  #2  
Silent Monkey
Scooby Regular
 
Silent Monkey's Avatar
 
Join Date: May 2001
Posts: 432
Likes: 0
Received 0 Likes on 0 Posts
Post

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.
Old 28 August 2003, 12:01 AM
  #3  
stu200
Scooby Regular
iTrader: (1)
 
stu200's Avatar
 
Join Date: Apr 2001
Posts: 531
Likes: 0
Received 0 Likes on 0 Posts
Smile

Damn you monkey I've been off rummaging round in some old books to find the answer and when I get back, you've gone and beaten me to it

Further info can be found here.
Old 28 August 2003, 09:03 AM
  #4  
Silent Monkey
Scooby Regular
 
Silent Monkey's Avatar
 
Join Date: May 2001
Posts: 432
Likes: 0
Received 0 Likes on 0 Posts
Post



Don't you just hate it when that happens.

I find This site a useful reference.

It can be done using W9x or DOS but gets really messy.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
blackieblob
ScoobyNet General
4
01 October 2015 11:37 AM
yabbadoo4
ScoobyNet General
11
30 September 2015 10:33 PM
Nick_Cat
Computer & Technology Related
2
26 September 2015 08:00 AM
Littleted
Computer & Technology Related
0
25 September 2015 08:44 AM



Quick Reply: DOS batch file help



All times are GMT +1. The time now is 09:48 AM.