home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Big Blue Disk 10
/
bbd10new.zip
/
DO.DOC
< prev
next >
Wrap
Text File
|
1987-05-22
|
5KB
|
135 lines
|D╔══════════════════╗════════════════════════════════════════════════════════════
|D║ |5The Happy Hacker |D║════════════════════════════════════════════════════════════
|D╚══════════════════╝════════════════════════════════════════════════════════════
^C^1KRAMDEN UTILITIES: THE DO COMMAND
^Cby
^CBryan Higgins
The |E~1Kramden Utilities^N are a set of programs which perform many PC functions.
We use them as in-house tools, and find them extremely useful. Whether you are
a hacker or an ordinary user, these utilities will help you make efficient use
of your personal computer.
These programs cannot be run directly from the menu. They work just like DOS
commands (such as COPY, DIR, etc.); invoke them by typing their name followed
by whatever parameters are appropriate. Before using any of the |E~1Kramden^N
|E~1Utilities^N, carefully read its instructions by selecting the |9~3Big Blue Disk^N menu
entry for the utility.
While each |E~1Kramden Utility^N is useful by itself, they can also work together
to do even more. Copy all |E~1Kramden Utilities^N onto one floppy disk or one
subdirectory of a hard disk. Documentation for each utility describes the ways
it can be used in combination with the others. Make sure not to miss an issue
of |9~3Big Blue Disk^N, so you can get a complete set. (Subscription information is
available elsewhere in this issue.)
^C^1THE DO COMMAND
The |E~1DO^N command is used in conjunction with the |E~1LS^N command. (|E~1LS^N appeared in
|9~3BIG BLUE DISK^N #4.) As you might remember, |E~1LS^N is used to list directory files.
Normally, |E~1LS^N output goes to the screen, but the information can also be "piped"
to other commands. In other words, |E~1LS^N can tell commands like |E~1DO^N which files to
work with.
And just what does |E~1DO^N do? |E~1DO^N reads a list of filenames piped to it by |E~1LS^N, and
writes these filenames to a batch file that is then executed.
Let's look at an example. Say that you want to copy all files with a ".c" or
".obj" extension to a disk in Drive B. First, the |E~1LS^N filter option is used to
find the files to be transfered:
^C^1ls -f *.c *.obj
This information is then piped to the |E~1DO^N command:
^C^1do copy & b:; del &
The entire command would look like this:
^C^1ls -f *.c *.obj || do copy & b:; del &
where "&" represents the files that are found. For each filename piped to |E~1DO^N,
the command writes two lines into a temporary batch file:
^C^1copy <file> b:
^C^1del <file>
The batch file is then executed and deleted. (Notice how the semi-colon ";"
was used split the lines in the batch file.)
^CSpecial Characters
These characters have special meaning within a |E~1DO^N command line, indicating
items which are substituted for the character when |E~1DO^N is invoked:
& -- substitutes the filename
^^ -- substitutes the disk portion of the filename (with trailing colon)
@ -- substitutes the directory portion of the filename (no trailing backslash)
# -- substitutes the file extension of the filename (no leading dot)
% -- substitutes the filename without the directory and file extension (no
trailing dot)
(These characters are often necessary to specify how filenames are written to
the batch file -- they are especially important when renaming files or
manipulating files found in sub-directories.)
Here's an example: suppose you want to copy all files with a ".dat"
extension to new files with a with a ".sav" extension to signify that they have
been saved. First, to make sure that |E~1LS^N looks in all sub-directories, you
must use its "-r option":
^C^1ls -rf *.dat || do copy & @\%.sav
|E~1DO^N converts the "& @\%" string to the filename without an extension. (Notice
that you must include a backslash after the "@" character.)
^COptions
Several options can be used with the |E~1DO^N command:
-v -- requests confirmation before processing each file. "Y" processes the
file; "N" skips that file. "!" processes the file and eliminates future
prompts.
-o -- causes commands to be written to the standard output rather than being
executed.
-1 -- causes |E~1DO^N to process the command only once, replacing the "&" character
with all the files piped to the |E~1DO^N command. In other words, instead of writing
commands one per line in the batch file like this:
^C^1__ <file>
^C^1__ <file>
this option writes the commands on one line:
^C^1__ <file> <file> <file> ...
Note: the "^^%#@" characters should not be used with this option.
^CFinal Notes
These characters are used in |E~1DO^N command lines to substitute for characters
which would otherwise be interpreted by DOS:
{ -- substitutes "<"
} -- substitutes ">"
! -- substitutes "|"
Finally, "'" eliminates any special meaning of the character which immediately
follows it (e.g. '@,'#.'%, or '&).
^CCopyright (c) 1985, 1986 by Bryan Higgins
DISK FILES THIS PROGRAM USES:
^FDO.EXE