home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- R M D
-
- Safe Directory Tree Deleter
-
- version 2.00
-
- (C) 1994 Richard Schaaf
-
-
- RMD V2.00 2 1 Feb 94
-
-
-
-
-
-
-
-
- TABLE OF CONTENTS
-
- 1. Copyright Stuff and Disclaimer........................ 3
- 2. Introduction.......................................... 3
- 3. System Requirements................................... 3
- 4. Installation.......................................... 3
- 5. Usage................................................. 4
- 5.1 Syntax.......................................... 4
- 5.2 Disabling/Enabling Individual Checks............ 4
- 5.3 Optimization.................................... 5
- 5.4 Move Up Mode.................................... 5
- 5.5 Verbosity Levels................................ 6
- 5.6 Help System..................................... 7
- 5.7 Environment Variables........................... 7
- 5.7.1 The NO_RMD variable...................... 7
- 5.7.2 The RMD_SW variable...................... 7
- 6. Command Line Parsing.................................. 8
- 7. Hints/Tips............................................ 8
- 8. Author................................................ 9
- 9. Planned Enhancements.................................. 9
- 10. History...............................................10
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- RMD V2.00 2 1 Feb 94
- RMD V2.00 3 1 Feb 94
-
- 1. Copyright Stuff and Disclaimer
- =================================
-
- This program is freely distributable provided that all files in
- this archive are distributed together. Please keep in mind that the
- author is the exclusive copyright holder. You may use this program
- as you seem fit but you are not allowed to make modifications to it
- without the explicit consent from the author.
-
- The author cannot be held responsible for damage (including lost
- files) incurred, either direct or indirect, by using the files in this
- archive. The author also does not guarantee the program will work
- as indicated in this file although every effort has been made to
- make sure it does. If you find an instance where it does not work
- as documented, please report it to the author at the address stated
- in section 8.
-
- 2. Introduction
- ===============
-
- This command recursively removes directory trees. The idea behind
- using RMD and not "alias rmd=del /s/x/z" or "alias rmd=del /s/x/y/z"
- is that the former always asks for acknowledgment (leading to an
- automatic "Y" answer after some time) and the latter never asks anything
- (leading to unintended deletes).
-
- RMD tries to predict whether the directory it is about to delete is
- a directory that the user actually wants to delete. If it thinks the
- operation is suspect, it will ask the user for confirmation, otherwise
- it will just go ahead and delete it.
-
- If you find RMD useful, please send me a postcard at the address in
- section 8.
-
- IN ANY CASE, SEND ME EMAIL IF YOU CAN. THAT IS THE ONLY WAY YOU WILL
- BE KEPT INFORMED ABOUT UPDATES AND GET SWIFT REPLIES TO BUG REPORTS AND
- ENHANCEMENT REQUESTS.
-
- 3. System Requirements
- ======================
-
- A PC running DR/PC/MS-DOS 3.3 or higher and 4DOS5.0c or later.
-
- 4. Installation
- ===============
-
- Start "install.btm". This program will guide you through the installation
- process.
-
- Finally, decide where you would like RMD to put its temporary file. RMD
- uses the following algoritm for determining where to put its temporary
- file:
- if 4DOSTEMP is set then use it
- else if TEMP is set then use it
- else if TMP is set then use it
- else use the root directory of the boot drive
- end if
-
- RMD V2.00 3 1 Feb 94
- RMD V2.00 4 1 Feb 94
-
- 5. Usage
- ========
-
- 5.1 Syntax
- ----------
- RMD [del flags] [answer flags] [/o<123>] [/u<012>] [/v[v]] [/c] [/h] [/?] dirs
- Where : delete flags = flags that are passed to the "del" command
- (all flags that rmd does not recognize are
- passed to the del command)
- answer flags = assume yes for certain checks (section 5.2)
- /o1 /o2 /o3 = optimize directories (section 5.3)
- /u0 /u1 /u2 = move up flags (section 5.4)
- /v and /vv = verbosity level; will give more information
- (section 5.5)
- /c = display copyright and version information
- /h and /? = starts the on-line help system (section 5.6)
- dirs = one or more directories that should be deleted
-
- RMD will warn the user if a directory is suspect, or better:
- - if the directory is not on the current drive, and/or
- - the directory is the root directory of a drive, and/or
- - the directory is "higher" than the current directory, and/or
- - the delete would delete a directory in the NO_RMD variable
- (section 5.7.1)
- (This is only true if the check has not been disabled, see section 5.2)
-
- If a directory is suspect the user will be asked for confirmation.
- At that point the user has the following options:
- Y = Delete this directory
- N = Skip this directory
- A = Always delete (don't check for suspect directories)
- Q = Quit (don't delete anything)
- H = Help
- ! = Shell out to 4DOS (COMSPEC has to be set for this to work)
-
- An argument is always skipped if:
- - the argument is on a drive that is not ready
- - the argument does not exist
- - the argument exists but is not a directory
- - the argument is a directory on a CD-ROM
- - the argument is a directory on a network drive (unless overridden with
- /y+w:<drives>)
-
- 5.2 Disabling/Enabling Individual Checks
- ----------------------------------------
-
- Individual checks can be disabled or enabled with the "answer flags".
-
- The answer flags disable (/y+) or enable (/y-) individual check for
- specific drives. Checks that can be disabled or enabled are:
-
- The different drive check (type=D)
- The root directory check (type=R)
- The higher directory check (type=H)
- The NO_RMD check (type=N)
- The network drive check (type=W)
-
- The complete definition of the answer flags is as follows:
- RMD V2.00 4 1 Feb 94
- RMD V2.00 5 1 Feb 94
-
- answer flags = [/y+<type>[:drives]] [/y-<type>[:drives]] [/yes] [/fd]
- where /yes = /y+d/y+r/y+h/y+n
- /fd = /y+d:AB/y+r:AB
-
- If no drives are specified, the flag applies to all drives.
-
- Example: /y+d/y-d:c disabled the different drive check unless
- that other drive is drive C
-
- 5.3 Optimization
- ----------------
-
- There are two kinds of optimization. The first kind (/o1) removes directories
- that will be deleted anyway from the list of directories. For example:
- "rmd /yes .. ..\q" in "c:\tmp" will be translated to "del /s/x/y/z c:\ c:\q",
- but "c:\q" will have been deleted already by the "del /s/x/y/z c:\". If you
- specify the "/o1" flag, rmd will execute "del /s/x/y/z c:\"
-
- Note that specifying the "/o1" flag does not only reduce the number of
- parameters to the "del" command but also prevents some accidental deletes.
- Assume there is a file "c:\test\q. Consider "rmd q q" in "c:\". This will
- be translated to "del /s/x/y/z q q". The first "q" will delete the directory
- "c:\q", as expected and as probably intended. The second "q", however, will
- remove all files named "q" on drive C, including "c:\test\q" !!!
-
- Now consider "rmd /o1 q q". In this case, RMD will notice that the intended
- delete is "del /s/x/y/z q" and not "del /s/x/y/z q q". Therefore it will
- delete the directory "c:\q" and not the file "c:\test\q".
-
- The second kind of optimization (/o2) does not modify which directories
- are passed to the "del" command, but does modify the way they are passed
- to that command. When "/o2" is not given, all directories will be fully
- expanded before they are passed to the "del" command. For instance, issuing
- "rmd ." in "c:\tmp" will be translated to "del /s/x/y/z c:\tmp". This may
- lead to command lines that are too long to be handled.
-
- When the "/o2" flag is given, RMD will try to make the parameters as short
- as possible. To do this it will try whether specifying a directory relative
- to the current directory is more efficient than specifying it fully expanded.
- When issuing "rmd /o2 ." in "c:\tmp", rmd will issue the command
- "del /s/x/y/z .". Note that "rmd /o2 c:\tmp" in "c:\tmp" will also be
- translated to "del /s/x/y/z ."
-
- The "/o3" flag is equivalent to "/o1/o2".
-
- 5.4 Move Up Mode
- ----------------
-
- The moveup mode determine what happens if you delete a directory that is
- higher than the current directory.
-
- /u0 : don't move up the directory tree
- /u1 : move up unless the directory starts with "."
- /u2 : always move up the directory tree
-
- (See example below)
-
-
- RMD V2.00 5 1 Feb 94
- RMD V2.00 6 1 Feb 94
-
- When using "/u0" (the default), all files will be deleted but the directories
- leading to the current directory will be left as they were before the delete
- operation.
-
- Using "/u2", everything below the highest directory parameter that is in the
- list of directories leading to the current directory is deleted.
-
- Option "/u1" is an intermediate. It does the same as "/u2" unless the
- directory parameter starts with ".". In that case, this directory will be
- left on the disk. (Any help with clarifying this paragraph is greatly
- appreciated!)
-
- Example: assume the directory structure of drive C is as follows:
- C:\
- └───A
- ├───B
- │ └───D
- └───C
- and the current directory is "c:\a\b\d"
-
- For n=0,1,2, the command "rmd /yes/u<n> .. ..." will delete
- all files in "\a", "\a\b", "\a\c" and "\a\b\d". Furthermore, the
- resulting directory tree and the current directory are listed in
- the following table:
-
- ┌────────┬────────────────┬───────────────────┐
- │ switch │ directory tree │ current directory │
- ╞════════╪════════════════╪═══════════════════╡
- │ /u0 │ C:\ │ c:\a\b\d │
- │ │ └───A │ │
- │ │ └───B │ │
- │ │ └───D │ │
- │ │ │ │
- │ /u1 │ C:\ │ c:\a │
- │ │ └───A │ │
- │ │ │ │
- │ /u2 │ C:\ │ c:\ │
- └────────┴────────────────┴───────────────────┘
-
- However, "rmd /yes/u1 c:\a\b c:\a" gives the same result
- as "rmd /yes/u2 .. ...".
-
- 5.5 Verbosity Levels
- --------------------
-
- There are two verbosity levels:
- /v : - display the directory that is currently being looked at
- - display "performing optimization" when optimization is enabled
- - before the del operation, display the number of
- directories that have been skipped
- - display the del command that will be performed
- /vv : - display the /y+ options in effect for the directory
- that is currently being looked at
- - display the directory that is currently being looked at
- - display "performing optimization" when optimization is enabled
- - before the del operation, display the number of
- directories that have been skipped
- - display the del command that will be performed
- RMD V2.00 6 1 Feb 94
- RMD V2.00 7 1 Feb 94
-
- 5.6 Help System
- ---------------
-
- The help system consists of a number of screens that contain an extract of
- the information in this document. At any time you can jump to any page by
- pressing the page number. Furthermore, <Page Up> takes you to the next
- page, <Page Down> to the previous page, <Home> to the first page, and
- <End> to the last page. Press <escape> to exit the help system.
-
- 5.7 Environment Variables
- -------------------------
-
- 5.7.1 The NO_RMD variable
-
- If you want to protect certain directories against accidental removal
- you can include them in the "NO_RMD" environment variable. The format
- of this variable is "<directory(1)>;.....;<directory(n)>". All directories
- in the "NO_RMD" variable should end with a "\" character. For instance,
- "c:\tmp\" is a valid value for the "NO_RMD" variable whereas "c:\tmp" IS NOT!
-
- If rmd would delete a directory that is in the NO_RMD variable, RMD will
- warn you.
-
- Note that this is different from previous versions of RMD. Previous versions
- only warn if you tell it to delete a directory in the NO_RMD variable, not
- if the deletion is caused by the deletion of a directory that is higher in
- the directory tree. For example, assume that "NO_RMD=c:\a\b\". In this
- situation, RMD versions previous to this one would warn if you entered
- "rmd c:\a\b", but not it you entered "rmd c:\a". From now on, RMD will warn
- in both cases.
-
- 5.7.1 The RMD_SW variable
-
- The "RMD_SW" environment variable contains default switches for RMD. The
- advantage is that "RMD_SW" is parsed before the command line. The difference
- of defining default switches with "RMD_SW" and not with
- "alias rmd=c:\4dos\rmd.btm <options>" will be further explained in the
- section "Command Line Parsing".
- RMD V2.00 7 1 Feb 94
- RMD V2.00 8 1 Feb 94
-
- 6. Command Line Parsing
- =======================
-
- The usage of RMD is not as rigid as mentioned above. In reality, switches
- and directories can be mixed almost arbitrarily. Not all flags apply to the
- entire commandline. To determine which flags apply, RMD uses the following
- algorithm.
-
- parse the flags in "RMD_SW"
- max_parameter := #of parameters
- parse all flags at the end of the command line (assume there are n
- parameters with flags at the end of the command line)
- max_parameter := max_parameter - n
- for i = 1 to max_parameter
- if parameter(i) contains flag(s) then # f.i. /fd or ./yes
- parse the flag(s)
- end if
- if parameter contains a directory then
- perform checks on directory using current options
- if OK to remove then
- add it to the list
- end if
- end if
- next i
-
- Note that all flags apply from where they occur up until the end of the
- command line. There are exceptions to every rule, therefore let me state
- the exceptions to this rule:
-
- - flags that are passed to the DEL command are applied to the entire
- command line
- - the /o1, /o2 and /o3 apply to the entire command line
-
- WARNING: using the "/u0", "/u1" and "/u2" flags can produce unpredictable
- results when used after the first directory.
-
- Because of the way RMD parses the parameters, it may be better to define
- default options in the "RMD_SW" environment variable and not in an alias.
- Let me give an example:
-
- Personally I want the following default options: "/fd/u1/o3". If we define
- "alias rmd=c:\4dos\rmd.btm /fd/u1/o3" everything works fine until we
- want to override the "/u1" by using "rmd . /u2". The "/u2" is parsed first,
- setting the "move up mode" to 2. Next the "/fd/u1/o3" is parsed, resetting
- the "move up mode" to 1.
-
- Alternatively, we could define "alias rmd=c:\4dos\rmd.btm %& /fd/u1/o3", but
- again, if we try "rmd . /u2", the "/u2" will be overridden.
-
- Now consider using "RMD_SW=/fd/u1/o3". In this case, the "/u1" will be parsed
- before the "/u2" flag, thus the "/u2" will override the "/u1" as intended.
-
- 7. Hints/Tips
- =============
-
- Instead of using the "rmd.btm" file directly, you can define an alias "rmd"
- that calls "rmd.btm" and includes your favorite switches. Personally I have
- defined "rmd=c:\4dos\rmd.btm /fd/u1/o3"
- RMD V2.00 8 1 Feb 94
- RMD V2.00 9 1 Feb 94
-
- 8. Author
- =========
-
- While I could tell all sorts of interesting stories about myself, let me
- keep it with name and address for now. If you have any requests for
- enhancements or bug reports (seems impossible :) please email or write:
-
- Richard Schaaf
- Walcherenstraat 2
- 1025 PN Amsterdam
- the Netherlands
- internet: rscha@ctp.com
-
- In any case, SEND ME A POSTCARD!
-
- Also: If you have an urge to give me money, CDs (Simtel?), Games,
- or anything else, please don't hesitate! :-))
-
- 9. Planned Enhancements
- =======================
-
- At this point, the "/o2" flag always leaves directories on drives other
- than the current one fully expanded. I'm currently considering how useful
- it is to change this.
-
- RMD currently does not support include lists ("c:\a;b"). This may or may
- not be implemented in a future release.
-
- I would like to, somehow, integrating the RMD help with the 4DOS help
- system. As soon as JP software sends me the 4DOS utility disk I ordered,
- I will see whether this is possible with the help compiler on that disk.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- RMD V2.00 9 1 Feb 94
- RMD V2.00 10 1 Feb 94
-
- 10. History
- ===========
-
- v2.00 Feb. 1, 1994 Corrected some errors in the manual
- Added warning if RMD would delete a directory in the
- NO_RMD variable but that directory is not one
- of the parameters
- Added RMD_SW variable
- Changed command line parsing
- Added /o1, /o2, /o3 flags
- Added "Shell out" capability at warning messages
- /vv no longer displays the individual checks
- /v and /vv display "performing optimization" when
- the /o1, /o2 or /o3 flag is given
- /noenv is ignored (obsolete)
- change in behavior of /u1 flag
- v1.10 Jan. 25, 1994 (internal beta version)
- Total rewrite of time-critical parts in C
- Separate versions for 8088/8086/80186/V20/V30,
- 80286 and 80386/80486/80586
- Added installation program
- Minor bugfixes
- v1.02 Jan. 19, 1994 (Never released)
- <esc> is now equivalent to "Q" at the warnings
- Minor performance enhancement
- v1.01 Jan. 17, 1994 Added environment space checking
- Added the /noenv flag
- Added drive ready check
- Added CD-ROM checking
- Added network checking
- Added /y+w flag
- Added /u0 /u1 /u2 flags
- Fixed some spelling errors
- v1.00 Jan. 12, 1994 First released version
- v0.99 Jan. 4, 1994 Final test version. Thanks to Michael
- Schaap (mscha@ctp.com) for helping me with
- testing and debugging this one!
-
-