|
Processing All Lines in a File
|
|
|
Present in every other decent OS and in many utilities, the
ability to supply a file containing a list of arguments for processing
is absent in MS-DOS.
If you've managed to get this far, I have to assume you
know how to take a list like:
data1
data2
data3
and add key words to the beginning of each line:
Enter new date: data1
Enter new date: data2
Enter new date: data3
or add words to the beginning of the file:
PROCESS.BAT data1
data2
data3
If you don't know how, go back and look at my page on processing
lines of data.
It really doesn't matter what words you add . The concept here is the
same. In this example, the goal is to create a batch file which will end
up running with "data1" as one of it's arguments. The problem is that the
batch file will be "run", not CALLed. Sooo... the first line containing
"data1" would be processed, and nothing else would. This kind of behavior
is not generally desired.
-
The most obvious solution is to start each line with the word "CALL" followed
by the name of your process batchfile. That can be done by writing
a filter with QBASIC or DEBUG.
-
The purest DOS way would be to take an entirely different approach. Intentionally
only process the first line. Then strip that line from the file.
Then process the next line. And so on. Very disk-intensive.
-
By far the coolest method (because it is so obscenely complex) is to rename
LOADFIX.COM and use it in ways you would never figure out without
being told.
Lastly, let me encourage you not to write any big batch list processing
program unless you have to. If your list (whatever it is) is automatically-generated,
it makes sense to process it using one of the above techniques. But if
you manually generate your list, spend an extra minute with Word (or any
other fancy word processor) converting your file list into a batch program.
With Word's replace function, you can insert things at the beginning or
end of your lines and even add new lines. Aside from having to fix up the
first and last lines when you're done, it's the easiest way to do things.
I've put together a little example here that shows
me using DOS to get a list of every text file in my "Program Files" directory,
then using Word to convert that list into something that will put each
file name (since they are long file names) into the environment
before calling another separate processing batch file.
Lost? Look at the site map.
Bad links? Questions? Send me mail.