Rexx Utils of disk utilities
Автор: Gordon Snider
Скачать в ZIP архиве
This is the README file that goes with the REXUTILS.ZIP v1.1
package of disk utilities, by Gordon Snider
Please send all communication regarding these to
The latest version of these utilities can be found at Hobbes
for FTP download
If you read this readme for an earlier version of the utilities
you should re-read this readme as changes have been made
throughout and are not marked.
The files in this package are:
NAME VERSION DESCRIPTION
README.TXT 1.1 this file;
BYTES.CMD 1.0 totals the number of bytes occupied by
the branch named as the subdirectory
of the current current directory;
LRU.CMD 1.0 external routine to load and register
the REXXUtil Dynamic Load Library (DLL);
MF.CMD 1.0 creates a dummy file entry in a
RDD.CMD 1.2 deletes a subdirectory of the current
directory and all subdirectories and
TOUCH.CMD 1.0 updates the date and time stamp of a
file or all files in a directory;
TRE.CMD 1.1 draws a chart of a directory structure
from the current directory out;
VOLS.CMD 1.1 shows you all available local drives
and space used and space available.
I wrote these utilities in REXX just because I like working in
it. It is well integrated into OS/2. I don't have to worry
about things like, "Am I running in full screen or a window?"
It also makes the source code available to the user so the user
can see what is happening, no surprises; and the user has the
chance to modify the code for his own use.
These utilities were developed and used on a Pentium Pro 200MHz
computer with 64MB RAM running Classic REXX under Convenience
Pack 1. These utilities have been run under Object REXX as well.
However, except for TOUCH.CMD, they only use REXX features that
were available in OS/2 2.0, so they should run just fine on Warp
3 and Warp 4. TOUCH.CMD uses the SysSetFileDateTime() function
which was available but not documented in Convenience Pack 1.
I don't know how much earlier the function was actually added.
These utilities use functions from the REXX Utilities Dynamic
Link Library (RexxUtil DLL). This DLL contains extra REXX
functions specific to OS/2. The code to load the RexxUtil DLL
is adapted from an internal routine found in "Teach Yourself
REXX In 21 Days" by William F. Schindler and Esther Schindler.
To avoid duplicating the code in each utility I have moved the
internal routine into an external routine, LRU.CMD, and called
it from each utility. If you load the RexxUtil DLL at boot time
this code will be redundant. In that case, you won't need
LRU.CMD in your command file directory, but if LRU.CMD isn't
there you must remove the following line from each utility to
avoid a routine not found message.
if LRU() then exit
Several of these utilities use recursion to walk a directory
tree. REXX in OS/2 supports 100 levels of nested control
structures. This affects these utilities by setting a practical
limit of directory nesting of about 50 deep, from the current
directory, (which may or may not be the root \), to the farthest
'leaf'. If you have directories nested more deeply than this
the program will fail with message REX0011 Control Stack Full.
No damage will occur but TRE will not draw the full tree and RDD
will delete little or nothing, depending on when it hit the
boundary. Workaround is to use these utilities from a directory
closer to the 'leaf' directories of the tree, that is, do the
job in stages.
In the syntax diagrams for each utility some arguments and
switches may be enclosed in square brackets [...]. This means
that those arguments and switches are optional. The syntax
diagrams are in the comments at the beginning of the code in
each utility, and in this readme.
Some of my utilities have a switch, /T, that turns on Rexx
Tracing for debug purposes, or for those who are curious about
how the code operates. For those of you who are not familiar
with Rexx programming, if you get Tracing turned on by accident
and want to stop it, do this: The REXX interpreter will be
issuing a numbered line of code, showing the new values of the
variables and waiting for you to do something. The cursor will
be flashing at the bottom left corner of the screen with no
prompt. If you press ENTER the REXX interpreter will just issue
the next line of code, execute it, show the variables and wait
for you again. So, when the cursor is flashing at the bottom
left with no prompt, just type in the word EXIT and press ENTER.
This will abort execution of TRACE and the .CMD and should
return you to the OS/2 prompt.
Don't try CTRL+C. CTRL+C will do nothing.
By default TRE.CMD expects to use a codepage that provides the
line drawing characters. These are the vertical bar і at
decimal 179, the right angle А at decimal 192, the sideways T Г
at decimal 195 and the horizontal bar Д at decimal 196.
Codepage 437 is one codepage that does this. If you are using a
codepage that doesn't have these characters, you can still get
most of the benefits of TRE.CMD by using the /S switch. This
will use a space character instead of the graphics characters
and preserve the indenting of the directories.
Switches are used to modify the operation of utilities. You
have some flexibility in the way you enter switches. The
utility parses the command you enter, splitting the command at
the first '/'. Anything before that is used as an argument,
everything after that is switches. The standard way of entering
switches here is: space-slash-capital letter, e.g. /D /F /S.
However as long as you use a slash as the first character the
following would also work: /D/F/S or /D F S or /DFS. All of
these would invoke the /D, /F and /S switches. Lower case
letters may also be used.
Unzip REXUTILS.ZIP into your REXX command directory, or into a
temporary directory, and then COPY or MOVE LRU.CMD, plus the
utilities you want, into your REXX Command directory. That
directory should be added to your PATH statement in CONFIG.SYS
for easiest use.
/* BYTES.CMD REXX CMD by Gord Snider v1.0 2003/02/02 */
/* PURPOSE: shows the number of bytes occupied by a branch of a
SYNTAX: BYTES subdirectory | * [switches]
or BYTES /?
where subdirectory is the unqualified name of a
subdirectory in the current directory, or * is a literal,
meaning all subdirectories of the current directory plus
files in the current directory, (i.e. to check your
whole hard drive make the root the current directory and
use the '*' argument.)
/D switch lists each subdirectory included,
/F switch lists each file found in the branch,
/? switch produces a help screen and then exits.
BYTES.CMD can help you get a picture of where your disk space is
being used up. It will total up the file space of one entire
branch in the current directory or the file space of all the
branches in the current directory.
BYTES.CMD requires an unqualified subdirectory name from the
current directory. It will walk into that subdirectory, and
that whole branch, and total up the bytes used by all the files.
It will NOT add up any bytes in Extended Attributes.
If * is supplied instead of a subdirectory name, all
subdirectories and files in the current directory will be
included in the output.
The /D switch produces an output line showing the fully
qualified name for each directory.
The /F switch produces an output line for each file showing the
ADHRS attributes, size, date, time and fully qualified name of
The final, default output message is:
Total files: files Total bytes: bytes
/* MF.CMD (MakeFile) by Gordon Snider v1.0 2003/01/26 */
/* PURPOSE: Creates a file entry, by default in the current
SYNTAX: MF /?
or MF [filename] [/T]
where filename is the optional name of the file you want
to create. A path may be included with the filename to
place the file in any directory. If you don't supply a
will be used to create one in the current directory
beginning with temp. followed by three digits; and where
the following optional switches may be used:
/? displays a help screen and then exits,
/T turns on the REXX trace ?i
This utility creates a 2 byte file, (I think line feed-carriage
return) and a file entry in a directory. I found this useful
when I was testing the RDD.CMD utility and needed lots of
directory entries to work on. Default action is to create a
file, temp.??? , where each question mark is a system-chosen
digit, such that the 3 digits taken together will always produce
a file name unique in the directory. This will be placed in the
current directory by default.
If you specify a name for the file you can call it any legal
name. If you put an existing, fully specified path to a
directory in front of the filename the file will go there. If
you specify a non-existant directory, or the file can't be
created for any other reason, a 'File not created.' message
will be issued.
If the file is successfully created a message stating so is
The /? switch produces a short help file and then exits.
The /T switch turns on REXX trace, in interactive, single step
/* RDD.CMD REXX EXEC by Gordon Snider Version 1.2 2003/02/17 */
/* PURPOSE: From the current directory, prune a branch starting
with the unqualified subdirectory of the current directory
named as an argument.
SYNTAX: RDD /?
or RDD subdirectory [switches]
Optional switches (none, or /?, or one or more of the others):
/? (HELP) Shows a small help screen and exits.
/T (TRACE) Turns on the TRACE ?I command.
/S (SILENT) Skips the 'Really prune ...?' question and
the confirmation message.
/L (LIST) Lists each directory as it is entered.
/D (DIRECTORY) Lists each directory as it is removed.
/F (FILE) Lists each file as it is deleted.
/* There are 2 conditions that prevent the deleting of a
a. there are files in the directory, or
b. there are subdirectories in the directory.
This Exec takes these actions:
1 Calls the recursive procedure NEXT: passing the target
2 NEXT: Switches to the subdirectory specified as an
3 Executes SysFileTree looking for any subdirectories,
and records their names in a list as a compound variable.
A loop is set up to handle them, if any, in turn.
a. If there are subdirectories, takes the next unhandled
one and calls NEXT: procedure recursively, passing the
name of that first unhandled one, i.e. back to step 1.
but one step closer to a 'leaf' directory. Because of
the PROCEDURE statement of the NEXT: routine the names
of any unhandled directories are preserved by REXX
until the execution of the RETURN statement and a new
set of directory names in compound variables is
This is true for each level of directories until a
leaf directory is reached.
b. If there are no subdirectories in this directory then
a 'leaf' directory has been reached so SysFileTree is
called looking for files. If any are found they are
4 The RETURN statement executes. All variables associated
with the leaf directory just searched are abandoned, and
the list and loop of subdirectories of this level is
re-exposed and re-activated.
5 Control passes to the statement following the CALL.
6 The current directory is changed to be the parent of this
7 The leaf directory is deleted.
8 The next unhandled directory in the list is handled.
This utility prunes a whole branch of a directory tree. It is
used like the OS/2 commands MD and RD. In the current directory
you can create a subdirectory with MD, or remove an empty
subdirectory with RD. RDD removes a subdirectory that has
files/subdirectories in it.
RDD.CMD starts from the current directory which has one or more
subdirectories. One of those subdirectories is named as the
argument. That named subdirectory and everything in it will be
The default action is to issue messages
"Really prune branch starting at' argument"
"Enter 'Y' to prune, anything else to exit."
before working; and the message
"Pruned branch" argument
after successful completion.
The /S switch will skip these two messages.
IT ALSO SKIPS THE CHANCE TO ENTER 'Y' OR EXIT
the /L switch lists each directory as it is
The /F switch shows each file as it is deleted.
The /D switch shows each directory as it is removed.
The /T switch turns on tracing in single-step interactive mode.
the /? switch shows a small help screen and exits.
Using the switch combination /L /D /F will show every directory
change and action the command makes as it moves through the
/* TRE.CMD REXX EXEC by Gord Snider 2003/01/12 v1.1 */
/* PURPOSE: To walk the directory structure from the current
directory and produce a screen display of the
subdirectories. By default the display goes out to the
This behaviour can be varied by a parameter and
SYNTAX: TRE /?
or TRE [depth] [switches]
where depth is a posiitive integer telling how many
levels deeper in the tree to display, and;
switch /? calls a simple help screen and exits;
/S tells the routine to use spaces instead of graphics
/D shows the number of directories in each directory;
/F shows the number of files in each directory;
/B shows the number of bytes in each directory.
This utility draws a chart of the directory tree starting from
the current directory and working its way out to the leaf
If the output is too long it can be piped into the MORE filter,
TRE | MORE
or redirected to a file, which can then be read with editors
E.EXE or EPM.EXE
TRE > DIR.TXT
The /? switch shows a Help screen and exits.
The /D, /F, /B switches produce numbers after each directory
name. You may specify none, one, two or three of these switches
in any order on the command line but the output is always that
the number of directories, if specified, will appear first, and
the number of bytes, if specified, will appear last, and the
number of files, if specified, will appear after the number of
directories and before the number of bytes. (You will only get
the numbers you ask for but their order of presentation on the
screen is fixed regardless of the order in which you request
The name TRE.CMD came about because the command TREE is already
in use. Since I like short names I just dropped the last 'E'.
By the way, I nominate this as the Rexx program with the fewest
clauses of code that can produce this output. Anyone know a
/* VOLS.CMD REXX Exec by Gord Snider Feb 2003 Version 1.1 */
/* PURPOSE: to display a list of LOCAL, writeable volumes
available with their partition letters, partition labels,
actual used space, per cent used space, actual free space,
per cent free space and total space.
Default is to show all such volumes in MegaBytes.
1 KB = 1024 B, 1 MB = 1024 KB = 1,048,576 B
SYNTAX: VOLS [partitions] [switches]
where optional partitions is a list of one or more
partition letters with colons and spaces,
e.g. VOLS C: D: E:
will show stats for volumes C: D: and E: which
must exist on your system
where optional switches may be
'/B' to show the results in bytes
'/?' to show a small help screen and exit
'/T' for debug to turn on the Trace function with ?i
This utility by default shows all your local drives with their
letters, labels, used space, used space per cent, free space,
free space per cent and total space. The default display is in
The capacity is 999,999,999,999 bytes for any one volume but
there is also the same capacity for the total of all volumes.
If you only want this information for 1 or more drives specify
which drive(s) in a list with colons and spaces, e.g.
VOLS C: D: J:
PLEASE NOTE: When the output is shown in MegaBytes (the default)
because a megabyte is 1,048,576 bytes, the numbers in the
columns will appear not to add up. It is not operating in base
10. If you want to check the numbers adding up select the
/B (bytes) switch.