home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / xt302.zip / XT.DOC < prev    next >
Text File  |  1992-07-06  |  21KB  |  502 lines

  1. ═════════════════════════════════════════════════════════════════════
  2. XT 3.02 [Jul 06 1992]     Copyright (c) 1991, 1992 by Paul Whittemore
  3. ═════════════════════════════════════════════════════════════════════
  4.  
  5. Summary
  6. ═══════
  7. See the license agreement at the end of this  document  before  using
  8. this program.  Don't worry, it's as liberal as they get.
  9.  
  10. What is XT?    A lot of people demanded this one.   It is one of the
  11. single most important utilities I have (next to my text editor and a
  12. couple others).  It has a single general goal, but in accomplishing 
  13. this goal, the program becomes a multi-purpose utility.
  14.  
  15. XT's goal is to provide a general way of traversing a DOS directory
  16. structure performing an arbitrary operation on a subset of the files
  17. found.  In many ways it resembles an improved version of earlier
  18. 'SWEEP'-like utilities.  Much user feedback has been applied since
  19. it's first incarnation and improvements continue to be made to the
  20. program.
  21.                               ══════════
  22.                                WARNING!
  23.                               ══════════
  24. WARNING:  This command is very powerful.  With power comes responsibility.
  25. If you are unsure of a command, do NOT use XT, or use the -n option to 
  26. test it first.  The author is not responsible for any loss due to the use
  27. (or abuse) of this program.
  28.  
  29.  
  30. Version 3
  31. ═════════
  32. Major changes have been made to the program for version 3.0.  Many of
  33. the existing features have been improved upon and many new features 
  34. have been added.
  35.                               ══════════
  36.                                WARNING!
  37.                               ══════════
  38. WARNING:  Version 3 is NOT compatible with all of the options and command
  39. template filter escapes of earlier versions!  Most batch files containing
  40. XT commands will need to be converted.
  41.  
  42.  
  43. Syntax
  44. ══════
  45.  
  46. This is perhaps the most difficult aspect of XT.  Although completely 
  47. consistent, many people find the command line very confusing.  The
  48. syntax is:
  49.  
  50.         XT  [<options> [<filespec> [<command-template>] ] ]
  51.  
  52. Before we get to the actual options, an explanation is in order.
  53.  
  54. XT will traverse a given directory tree applying a command for every
  55. match.  XT without a command template will simply list all matches.
  56. If no filespec (pattern) is specified, "*.*" is assumed.  The
  57. <command-template> field can be as long as DOS will allow the line
  58. and can specify any command including batch (.BAT) files.
  59.  
  60. Some examples:
  61.  
  62.   XT readme.doc
  63.     - displays the name of all README.DOC files in and under the 
  64.       current directory.
  65.  
  66.   XT
  67.     - displays the names of all files in and under the current directory.
  68.  
  69.   XT *.com
  70.     - displays the names of all files whose filename extension is '.COM'.
  71.  
  72.   XT readme.doc attrib +r readme.doc         
  73.     - mark the file readme.doc read-only 
  74.       (by executing the DOS ATTRIB command).
  75.  
  76. In the last example, "attrib +r readme.doc" is the <command-template>
  77. part of the command line.  Rather than retyping the name of the file
  78. (readme.doc), XT has special placeholders which begin with a dollar
  79. sign ($).  For example, $n represents the name (root + extension) of
  80. the file.  Thus, the previous command could have been abreviated to
  81. the following:
  82.  
  83.         XT readme.doc attrib +r $n
  84.  
  85. In fact, XT is recursive, so in this case it will search the current
  86. directory as well as all subdirectories for all occurrences of the
  87. file README.DOC.  Unfortunately (or perhaps fortunately?), it will
  88. execute the command "attrib +r readme.doc" once for each match so if
  89. there are four matching files, it will mark the SAME copy of README.DOC 
  90. in the current directory read-only each time, or in this case, 
  91. FOUR TIMES!
  92.  
  93. The solution depends on what you wanted to accomplish.  Getting a
  94. little ahead of things, there are many command line options,
  95. including the -r option which disables the recursive decent of the
  96. directory tree.  So the command:
  97.  
  98.         XT -r *.doc attrib +r $n
  99.  
  100. will mark read-only all files .DOC files in the CURRENT directory
  101. only.
  102.  
  103. If you wanted to mark ALL .DOC files in ALL subdirectories (and the
  104. current one) read-only, you could leave out the -r and substitute $f
  105. for $n:
  106.  
  107.         XT *.doc attrib +r $f
  108.  
  109. The full set of such template escape sequences is given below.
  110. Template Escape Codes
  111. ═════════════════════
  112. The following command template escape codes (placeholders) may occur
  113. as many times as desirable in the <command-template> part of the
  114. command line:
  115.  
  116.         $f  the full path name of the matching file or directory
  117.         $F  same as $f but with trailing '\' (if -d option used only)
  118.         $p  the base (common) part of the matching path
  119.         $P  same as $p but with trailing '\'
  120.         $d  the relative directory part of the matching path
  121.         $D  same as $d but with trailing '\'
  122.         $n  the filename & ext of the matching file or directory
  123.         $N  same as $n but with trailing '\' (if -d option used only)
  124.         $r  the root file name of the matching file or directory
  125.         $e  the extension name of the matching file or directory
  126.         $?  place marker for $\ escape code
  127.         $\  conditional path separator (\) if non-null since last $?
  128.         $$  a dollar sign ($).  '$' + anything else is that char.
  129.  
  130. Another example:  Assume your current directory is C:\TOPLEVEL and
  131. you execute the following command:
  132.  
  133.         XT *.doc
  134.  
  135. Let's say XT displays the following files:
  136.  
  137.         1.  C:\TOPLEVEL\README.DOC
  138.         2.  C:\TOPLEVEL\PERSONAL\RESUME.DOC
  139.         3.  C:\TOPLEVEL\SUBDIR1\README.DOC
  140.         4.  C:\TOPLEVEL\UTILITY\XT\XT.DOC
  141.         5.  C:\TOPLEVEL\UTILITY\LS304\LS.DOC
  142.         (The numbers are for reference below.)
  143.  
  144. The paths above represent the value of $f for each match.  The value
  145. of $p and $P are constant for each execution of XT, in this case they
  146. will have values of "C:\TOPLEVEL" and "C:\TOPLEVEL\", respectively.
  147. The quotes are for readability in this document only.  Note the trailing
  148. slash on the value for $P.  The values of the $d and $D are listed below:
  149.  
  150.         Match    $d               $D
  151.         ----- ---------------- ----------------
  152.           1      ""               ""              
  153.           2   "PERSONAL"       "PERSONAL\"
  154.           3   "SUBDIR1"        "SUBDIR1\"
  155.           4   "UTILITY\XT"     "UTILITY\XT\"
  156.           5   "UTILITY\LS305"  "UTILITY\LS305\"
  157.  
  158. In the examples above, $n is always "README.DOC", $r is always "README",
  159. and $e is always ".DOC".  The value of $f is always the concatenation of
  160. $P$D$n or $P$D$r$e.  Note that in the case of an empty value for any given
  161. escape code, the corresponding uppercase escape code will also be empty.
  162. (A backslash path separator (\) will NOT be appended to an empty path.)  
  163.  
  164. IMPORTANT:  The $\ escape code represents a conditional path separator.
  165. If the command template's expanded value since the last $? marker is 
  166. non-null, a slash will be appended at the point of the $\.  For
  167. example, "$?$d$\abc" will expand to "xyz\abc" if $d is "XYZ", but
  168. will expand to just "abc" if $d is empty (NOT "\abc").
  169. Options
  170. ═══════
  171. The following options can be specified before the <filespec> pattern
  172. (if present):
  173.  
  174.          -h, -?  displays this usage help
  175.              -r  non-recursive (do NOT scan subdirectories)
  176.              -c  change to directory of match before running command
  177.              -d  match directory names only
  178.              -q  enables quiet mode (includes -e)
  179.              -e  disables command echo
  180.              -n  do not execute commands (echo only)
  181.              -f  force continue with next match on program error return codes
  182.              -F  force continue with next match on Ctrl-C/Ctrl-Break in cmd
  183.              -p  patterned list of directories only
  184.              -s  disable line splitting
  185.           -s<c>  use character <c> for line separator (default ';')
  186.           -xext  exclude files with .ext extension
  187.              -!  force use of COMMAND.COM(COMSPEC) if not found
  188.         (-p assumes -n, just lists matches as in template specified)
  189.  
  190.  
  191. The -p option is useful in creating batch files.  For example, the
  192. command:
  193.  
  194.         XT -p *.doc copy $f d:\docs >copydocs.bat
  195.  
  196. might produce a file COPYDOCS.BAT containing:
  197.  
  198.         copy C:\TOPLEVEL\README.DOC d:\docs
  199.         copy C:\TOPLEVEL\PERSONAL\RESUME.DOC d:\docs
  200.         copy C:\TOPLEVEL\SUBDIR1\README.DOC d:\docs
  201.         copy C:\TOPLEVEL\UTILITY\XT\XT.DOC d:\docs
  202.         copy C:\TOPLEVEL\UTILITY\LS304\LS.DOC d:\docs
  203. A Word about (!) and (-!)
  204. ═════════════════════════
  205. For reliability, the program specified by the COMSPEC environment 
  206. variable (usually COMMAND.COM) is NOT used to execute a command (by 
  207. default).  When XT does not run programs directly, it cannot tell if
  208. execution was successful or not, neither can it detect what error code
  209. (if any) was returned by the program.  Furthermore, if a secondary program
  210. such as COMMAND.COM is used to execute the command, XT cannot tell if the
  211. command was aborted via Ctrl-C or Ctrl-Break keystrokes.
  212.  
  213. When given a command template to execute, XT will use the following
  214. procedure:
  215.     1.  If a path (relative or absolute) is part of the command name,
  216.         or if the command name contains a '.', the name will be used
  217.         as is.
  218.     2.  Otherwise, it will search the current directory, then each 
  219.         directory in the PATH environment variable for the specified 
  220.         program.  In each case, it will first look for a .COM file, 
  221.         then a .EXE file, and finally a .BAT file.
  222.     3.  If the matching file is a .BAT file, the command will be
  223.         executed via the program specified by the COMSPEC variable
  224.         (usually COMMAND.COM).
  225.     4.  If the matching file is a .COM or .EXE file, it will be executed
  226.         directly.
  227.     5.  If no matching file is found, XT will abort with an
  228.         appropriate error message.
  229.  
  230. If the command template starts with an exclamation mark (!), XT will
  231. always execute the command indirectly through the COMSPEC command
  232. interpreter, regardless of the matching file's extension.  In this
  233. case, XT will not be able to detect an error executing the program,
  234. except for errors executing the command interpreter itself.
  235.  
  236. The -! option forces the use of the COMSPEC interpreter for all
  237. commands regardless of the ! command prefix.
  238.  
  239. The ! command prefix should be used for commands which are builtin 
  240. to the command interpreter (such as COPY and DEL).
  241. A Word About The -d Option
  242. ══════════════════════════
  243. The -d option applies the pattern specified by <filespec> to
  244. directory entries rather than regular files.  The matching directory
  245. entry can be referenced by any of the escape codes including the $n 
  246. and $f escape codes, just like it is for matching files.  This can be 
  247. confusing but is, at least, consistent.
  248.  
  249. To list all directories starting with 'T', the following command
  250. would be used:
  251.  
  252.         xt -d t*.*
  253.  
  254. To remove all such directories, use one of the following:
  255.  
  256.         xt -d t*.* rd $f
  257.         xt -d t*.* rd $D
  258.  
  259. or, if your a 'real' geek,
  260.  
  261.         xt -d t*.* rd $P$D
  262.  
  263. Note that the point here is that $D *IS* sufficient.  When using
  264. the -d option, $d is the relative name of the *directory*, which in
  265. this case is the *whole* pathname of the matching entry, rather than
  266. 'just' the directory part.
  267.  
  268. Note also that the $n escape code is still important when using the 
  269. -d option.  Sometimes it is important to know just the last portion of
  270. a directory name.  The value of the $r and $e escape codes is unclear
  271. when using -d.  They will, however, represent the appropriate pieces
  272. of the $n.
  273.                               ══════════
  274.                                WARNING!
  275.                               ══════════
  276. WARNING:  This represents a significant change from the corresponding
  277. command under earlier versions of XT.  Most batch files containing XT
  278. commands will need to be converted.
  279. The -x Option
  280. ═════════════
  281. The -x option allows you to specify a list of files to AVOID
  282. matching.  For example, you wish to backup all files EXCEPT those
  283. with .BAK, .TMP and .$$$ extensions to the floppy in drive A:.
  284.  
  285.         XT -xbak -xtmp -x$$$ *.* copy $f a:
  286.  
  287. It is possible to group these into a single option, separated by
  288. commas (,):
  289.  
  290.         XT -xbak,tmp,$$$ *.* copy $f a:
  291.  
  292. When combined with the -d option, the arguments to a -x option
  293. represent the WHOLE directory name to avoid matching.  As in our
  294. example above:
  295.  
  296.         XT -d -xtemp -xbackup *.* copy $f\*.* a:
  297. or
  298.         XT -dxtemp,backup *.* copy $f\*.* a:
  299.  
  300. will copy all files from all directories under the current directory
  301. to drive A: EXCEPT those files in directories whose last pathname
  302. component is TEMP or BACKUP.
  303.  
  304.  
  305. The -s Option
  306. ═════════════
  307. XT normally allows you to specify multiple commands in a single
  308. command template.  Commands are separated by semicolons (by default).
  309. The following command displays all .TMP files, then deletes them.
  310.  
  311.         XT -! *.TMP type $f;del $f
  312.  
  313. Note the -! option is used since both commands are internal commands
  314. to COMMAND.COM.
  315.  
  316. This feature may be disabled via the -s option.  If the -s option is
  317. followed by a space, multiple command support is disabled. For
  318. example:
  319.  
  320.         XT -s *.TMP xyzdebug -sddir1;dir2 prog
  321.  
  322. Some command interpreters already support multiple commands per line. 
  323. To maintain complete compatability with these, you can redefine the
  324. command separator.  If the -s option is not followed by a space, the
  325. character which follows it is assumed to be an alternate command
  326. separator.  For example, if you wanted to use the tilde (~) character
  327. rather than the semicolon (;), the following command is equivalent to
  328. the first example above:
  329.  
  330.         XT -!s~ *.TMP type $f~del $f
  331.  
  332. Note that some characters are processed before XT sees the command
  333. line.  Characters used by the DOS command interpreter cannot be used
  334. as command separators (e.g. '<', '>', '|').
  335. File Attribute Options
  336. ══════════════════════
  337. If any of the following are specified, it is an explicit list of
  338. the include set (the directory entries to match):
  339.              +r  include read-only files
  340.              +w  include read-write files
  341.              +h  include hidden files
  342.              +s  include system files
  343.  
  344. For example, "XT +r" lists all read-only files in and under the
  345. current directory.
  346. Recent Revisions
  347. ════════════════
  348.  
  349. Version 3.02:
  350. ------------
  351. Fixed the problem with -r being ignored.
  352.  
  353. Version 3.01:
  354. ------------
  355. Fixed ! command prefix.  Also fixed use of extended ascii characters
  356. (those with high bit set, ascii 128-255).  Thought that I had all the
  357. cases where trailing path separators was a problem solved by the
  358. introduction of the uppercase escape codes (e.g. $D) but realized
  359. that was true only if they were followed by another escape code,
  360. spaces or end of line.  For fixed text, it was still a problem.  So I
  361. added $? and $\ escape codes.  I doubt the upper case equivalents are
  362. needed 
  363. codes.
  364.  
  365. Version 3.0:
  366. -----------
  367. Replaced program execution code to allow XT to check the programs'
  368. return codes.  Coded to abort on a non-zero return code.  This allows
  369. XT to abort more cleanly on a Ctrl-C/Ctrl-Break for programs and runtime
  370. libraries returning a non-zero.  Added -f and -F options to override the
  371. abort and force continuation regardless of the programs result status.
  372. Added multiple command syntax and -s<separator-char> override option.
  373. Split -q option into -q and -e for better control.  Responded to
  374. complaints about the way $d worked under the -d option by changing
  375. the escape codes' values.  Added the uppercase escape codes.  Added
  376. the '!' command prefix, the -! option and changed the way this all
  377. worked.
  378.  
  379. Version 2.4:
  380. -----------
  381. Added -x option for exclusion set.  The version was for Novell use
  382. and internal use only and was not widely distributed.
  383.  
  384. Version 2.3:
  385. -----------
  386. Added -c option.  When specified, XT will change the current
  387. directory and drive, if necessary, to the directory part of any
  388. matches found.  For directories matched via -d, this includes the
  389. whole directory ($f), not everything except the last component ($p$d).
  390.  
  391. XT will now always save the current directory on the current drive
  392. (only) and will restore it on normal or CTRL-BREAK termination.
  393.  
  394. Version 2.2:
  395. -----------
  396. Added attribute patterns (+r +w +h +s).  Recommend +r and +w use
  397. only, since +h and +s may not achieve desired results.  Try XT with
  398. the -n option to verify expectations.  
  399.  
  400. Options may be combined (e.g. +rh).
  401.  
  402.  
  403. Version 2.1:
  404. -----------
  405. A lot of people have been pushing for improvements in my XTREE program,
  406. so over the weekend I upgraded it to use my PATHS library...  This combined
  407. with some other work results in several improvements:
  408.  
  409.     - You can now specify absolute or relative paths in front of the pattern.
  410.     - The command template filter/escape sequences have been revised to
  411.       allow the inclusion of the relative part of a matching path name ($d).
  412.     - The program now aborts cleanly on a Ctrl-Break signal.
  413.     - You can specify (-d) that the pattern should be used to match
  414.       *directory* names.
  415.     - The program is now recursive by default.
  416.  
  417. Due to the incompatable changes to both the escape filtering and the defaults,
  418. combined with the fact that there is a commercial program named XTREE, I have
  419. decided to rename the executable to XT.EXE.
  420.  
  421.  
  422. More Examples:
  423. ══════════════
  424.  
  425.         XT ?   or   XT -?  or  XT -h
  426.  
  427.         Gives help, the command syntax and options.
  428.  
  429.  
  430.         XT *.c
  431.  
  432.         Like WHEREIS.  Displays all .C files under the current directory.
  433.  
  434.  
  435.         XT \*.c
  436.  
  437.         Like WHEREIS.  Displays all .C files anywhere on the current drive.
  438.  
  439.  
  440.         XT -d C:\X*.*
  441.  
  442.         WHEREIS for directories.  Finds all directories on drive C: that
  443.         start with an X.
  444.  
  445.  
  446.         XT -d c:*.* md d:$d
  447.  
  448.         Copies the directory structure existing under the current directory
  449.         on drive C: to the current directory on drive D:.  Note that $d is
  450.         the *relative* directory name, needed in this case.
  451.  
  452.  
  453.         XT c:*.c copy c:$f d:$d$n
  454.  
  455.         Recursively copies all .C files existing under the current directory
  456.         on drive C: to the corresponding current directory on drive D:.  Note
  457.         that $d is the *relative* directory name, and that the full path of
  458.         the matching (source) file is $f.
  459. License Agreement
  460. ═════════════════
  461. Use of this program is ALMOST completely without restriction.  Stupid
  462. little command-line utilities which aid the user in some small manner
  463. should not be restricted since a better working enviroment  helps  us
  464. all and may even lower the cost of more significant programs.
  465.  
  466. This program may NOT be sold or exchanged for any other consideration
  467. without express written consent of the author.  Where bundled as part
  468. of a larger collection of programs, this program may be  included  in
  469. cases where it does not represent a significant portion (greater than
  470. ten (10) percent) of the functionality of the product being sold.  It
  471. may be included in sales of public domain software disks provided the
  472. charge for such services does not exceed five dollars  ($5) U.S.  for
  473. the disk containing this program.  (I  know  that's  less  than  some
  474. folks charge, but come on guys,  twice  the  cost  of  the  disk  for
  475. something somebody else gave you for free should be enough!)
  476.  
  477. Other than  this  single  restriction,  this  program  may  be  used,
  478. distributed and/or included with other  products  provided  both  the
  479. program and this document file are included  unchanged.   This  means
  480. that you can use it at home or at  work,  company  software  and  LAN 
  481. administrators can distribute  to  it  to  fellow  employees  without
  482. reservation and you can even provide it as  a  bonus  with  your  own
  483. termination emulation, email or other fine product.
  484.  
  485. Due to the nature of this program, the author wishes to make it clear
  486. that the use of this utility is subject to the discretion of the user
  487. and that no implied warrantee exists.   The  author  will  accept  no
  488. responsibility for its use.  There are no  intentionally  destructive
  489. 'features', however commands like "XT *.* del $f" could have  serious
  490. impact on the user's blood pressure (not to mention the hard disk).
  491.  
  492. The author can be contacted at the following addresses:
  493.  
  494.                 Paul Whittemore
  495.                 853 Grenoble Blvd.
  496.                 Pickering, Ontario
  497.                 Canada     L1W 1T7
  498.  
  499. CompuServe:     72007,3305
  500. Internet:       pwhittem@novell.com
  501. MHS:            pwhittem@novell
  502.