home *** CD-ROM | disk | FTP | other *** search
/ Big Blue Disk 10 / bbd10new.zip / DO.DOC < prev    next >
Text File  |  1987-05-22  |  5KB  |  135 lines

  1. |D╔══════════════════╗════════════════════════════════════════════════════════════
  2. |D║ |5The Happy Hacker |D║════════════════════════════════════════════════════════════
  3. |D╚══════════════════╝════════════════════════════════════════════════════════════
  4.  
  5. ^C^1KRAMDEN UTILITIES:  THE DO COMMAND
  6. ^Cby
  7. ^CBryan Higgins
  8.  
  9.    The |E~1Kramden Utilities^N are a set of programs which perform many PC functions.
  10. We use them as in-house tools, and find them extremely useful.  Whether you are
  11. a hacker or an ordinary user, these utilities will help you make efficient use
  12. of your personal computer.
  13.  
  14.    These programs cannot be run directly from the menu. They work just like DOS
  15. commands (such as COPY, DIR, etc.); invoke them by typing their name followed
  16. by whatever parameters are appropriate.  Before using any of the |E~1Kramden^N
  17. |E~1Utilities^N, carefully read its instructions by selecting the |9~3Big Blue Disk^N menu
  18. entry for the utility.
  19.  
  20.    While each |E~1Kramden Utility^N is useful by itself, they can also work together
  21. to do even more.  Copy all |E~1Kramden Utilities^N onto one floppy disk or one
  22. subdirectory of a hard disk.  Documentation for each utility describes the ways
  23. it can be used in combination with the others.  Make sure not to miss an issue
  24. of |9~3Big Blue Disk^N, so you can get a complete set.  (Subscription information is
  25. available elsewhere in this issue.)
  26.  
  27.  
  28. ^C^1THE DO COMMAND
  29.  
  30.   The |E~1DO^N command is used in conjunction with the |E~1LS^N command.  (|E~1LS^N appeared in
  31. |9~3BIG BLUE DISK^N #4.)  As you might remember, |E~1LS^N is used to list directory files.
  32. Normally, |E~1LS^N output goes to the screen, but the information can also be "piped"
  33. to other commands.  In other words, |E~1LS^N can tell commands like |E~1DO^N which files to
  34. work with.
  35.  
  36.   And just what does |E~1DO^N do?  |E~1DO^N reads a list of filenames piped to it by |E~1LS^N, and
  37. writes these filenames to a batch file that is then executed.
  38.  
  39.   Let's look at an example.  Say that you want to copy all files with a ".c" or
  40. ".obj" extension to a disk in Drive B. First, the |E~1LS^N filter option is used to
  41. find the files to be transfered:
  42.  
  43. ^C^1ls -f *.c *.obj
  44.  
  45. This information is then piped to the |E~1DO^N command:
  46.  
  47. ^C^1do copy & b:; del &
  48.  
  49. The entire command would look like this:
  50.  
  51. ^C^1ls -f *.c *.obj || do copy & b:; del &
  52.  
  53. where "&" represents the files that are found.  For each filename piped to |E~1DO^N,
  54. the command writes two lines into a temporary batch file:
  55.  
  56. ^C^1copy <file> b:
  57. ^C^1del <file>
  58.  
  59. The batch file is then executed and deleted.  (Notice how the semi-colon ";"
  60. was used split the lines in the batch file.)
  61.  
  62. ^CSpecial Characters
  63.  
  64.   These characters have special meaning within a |E~1DO^N command line, indicating
  65. items which are substituted for the character when |E~1DO^N is invoked:
  66.  
  67. & -- substitutes the filename
  68.  
  69. ^^ -- substitutes the disk portion of the filename (with trailing colon)
  70.  
  71. @ -- substitutes the directory portion of the filename (no trailing backslash)
  72.  
  73. # -- substitutes the file extension of the filename (no leading dot)
  74.  
  75. % -- substitutes the filename without the directory and file extension (no
  76. trailing dot)
  77.  
  78. (These characters are often necessary to specify how filenames are written to
  79. the batch file -- they are especially important when renaming files or
  80. manipulating files found in sub-directories.)
  81.  
  82.   Here's an example:  suppose you want to copy all files with a ".dat"
  83. extension to new files with a with a ".sav" extension to signify that they have
  84. been saved.  First, to make sure that |E~1LS^N looks in all sub-directories, you
  85. must use its "-r option":
  86.  
  87. ^C^1ls -rf *.dat || do copy & @\%.sav
  88.  
  89. |E~1DO^N converts the "& @\%" string to the filename without an extension.  (Notice
  90. that you must include a backslash after the "@" character.)
  91.  
  92. ^COptions
  93.  
  94.   Several options can be used with the |E~1DO^N command:
  95.  
  96. -v -- requests confirmation before processing each file.  "Y" processes the
  97. file; "N" skips that file.  "!" processes the file and eliminates future
  98. prompts.
  99.  
  100. -o -- causes commands to be written to the standard output rather than being
  101. executed.
  102.  
  103. -1 -- causes |E~1DO^N to process the command only once, replacing the "&" character
  104. with all the files piped to the |E~1DO^N command.  In other words, instead of writing
  105. commands one per line in the batch file like this:
  106.  
  107. ^C^1__ <file>
  108.  
  109. ^C^1__ <file>
  110.  
  111. this option writes the commands on one line:
  112.  
  113. ^C^1__ <file> <file> <file> ...
  114.  
  115. Note: the "^^%#@" characters should not be used with this option.
  116.  
  117. ^CFinal Notes
  118.  
  119.   These characters are used in |E~1DO^N command lines to substitute for characters
  120. which would otherwise be interpreted by DOS:
  121.  
  122. { -- substitutes "<"
  123.  
  124. } -- substitutes ">"
  125.  
  126. ! -- substitutes "|"
  127.  
  128. Finally, "'" eliminates any special meaning of the character which immediately
  129. follows it (e.g. '@,'#.'%, or '&).
  130.  
  131. ^CCopyright (c) 1985, 1986 by Bryan Higgins
  132.  
  133. DISK FILES THIS PROGRAM USES:
  134. ^FDO.EXE
  135.