DoList in LIST Mode

Prev Next Home Home Table Of Contents Index

DOLIST IN LIST MODE:

Did you ever want to execute a program on a LIST of files? DoList will execute a command line and substitute text from the standard input device in the command line. Suppose you have a file named "BAK.LST" that contains the following list of files:


 NOTES.BAK
 JOBS.BAK
 AUTOEXEC.BAK
 CONFIG.BAK

If you want to delete all the files in the list you type:


 DOLIST DEL @L < BAK.LST
        or
 TYPE BAK.LST|DOLIST DEL @L

DoList will then execute the following commands:


 DEL NOTES.BAK
 DEL JOBS.BAK
 DEL AUTOEXEC.BAK
 DEL CONFIG.BAK

DoList reads each line from the standard input device and executes the command for each line read. The @L causes DoList to insert the next input line into the command. Therefore, the command "DEL @L" is executed for each line from the standard input file, which in this case is BAK.LST.

Suppose you want to copy all your .BAT files on you hard disk to a floppy. This can be done by typing:


 WHEREIS *.BAT|DOLIST COPY @L A:

Adding @T to the command (WHEREIS *.BAT|DOLIST COPY @L A: @T) will cause DoList to type the commands instead of executing them. This output can be redirected into a file for later execution.

Summary of DoList Commands for LIST mode:


 @L        ;substitute next input line
 @1 .. @9  ;substitute field 1 thru 9
 @T        ;output commands as text instead of executing them
 @Q        ;query mode, displays command and asks for confirmation
 @[        ;substitutes < in command line
 @]        ;substitutes > in command line
 @]]       ;substitutes >> in command line
 @!        ;substitutes | in command line
 {}        ;commands in {braces} are not interpreted but passed as text

In addition to the @L command, which substitutes the whole line, DOLIST can look at the lines as fields that can be substituted individually. The individual fields are substituted by @1 thru @9. In the text line:


 456,NOTES.TXT "Marc Perkel"

@1 = 456 @2 = NOTES.TXT @3 = Marc Perkel

The rule is: commas and spaces are delimiters (characters used to separate fields or parameters) unless you start with a quote. If you start with a quote, the next quote is the delimiter.

If you don't want DoList to actually execute the commands, the @T command will cause DoList to output the text that it would have executed. This text can be redirected to a BAT file for later execution.

The @Q command makes DoList ask before executing each command line. This allows you to skip the command or abort DoList.


Example:

PIPEDIR *.BAT >BAT.LST Creates BAT.LST with list of all *.BAT files.

DOLIST COPY @IBAT.LST @L@T A: @OTEST.BAT Reads each line of BAT.LST and creates the command COPY [line] A: and writes these commands to a file named TEST.BAT.

Using braces '{}' suspends interpretation of @ commands allowing the @ to be part of the command. The outermost pair of braces are removed from the command. This is useful when using DoList recursively. That means using DoList to run DoList.

When a command line is presented to DOS, the redirection and piping commands, [ ] | are interpreted and removed. In order to pass these commands to a program that DoList can run, we must use other codes that DOS won't remove. The @[ is translated into <, the @] is translated into >, the @]] is translated into >> and the @! is translated into |.

Using DoList Recursively:

Lets say we have a file named X.LST that contains the lines:


 1
 2
 3

And a file named Y.LST that contains the lines:


 A
 B
 C

The following command produces the following results:


 DOLIST DOLIST @L{@L@T}@[x.lst <y.lst

A1 A2 A3 B1 B2 B3 C1 C2 C3

In this example, the outer DoList causes the inner DoList to be executed three times. It executes the lines:


 DOLIST A@l@t<x.lst
 DOLIST B@l@t<x.lst
 DOLIST C@l@t<x.lst

Notice that the outer DoList caused the first @L to be translated into A,B,C from Y.LST and that @[x.lst was translated into <x.lst. Also, note that the braces {} were removed but the interpretation of what was inside the braces is preserved for the inner DoList.

Prev Next Home Home Table Of Contents Index

Sponsors
Shopping
Forum
Forum
email
EMail
Index
Index
Home
Home