Dec 172017
"Bill's Unique Batch Arsenal" batch enhancers, version 2.0.
File BUBA2.ZIP from The Programmer’s Corner in
Category Batch Files
“Bill’s Unique Batch Arsenal” batch enhancers, version 2.0.
File Name File Size Zip Size Zip Type
ALLSET.EXE 5408 3279 deflated
BUBA.DOC 17783 6173 deflated
DISKSIZE.EXE 5216 2786 deflated
FILEFITS.EXE 4384 2828 deflated
FILESIZE.EXE 3872 2552 deflated
INPUT.EXE 5856 3469 deflated
ISEXT.EXE 4848 2823 deflated
ISREADY.EXE 4384 2657 deflated
JUSTNAME.EXE 5504 3321 deflated
PRNTSCRN.COM 4 4 stored
RANDFILE.EXE 6800 3971 deflated
SELECTOR.EXE 20896 11252 deflated

Download File BUBA2.ZIP Here

Contents of the BUBA.DOC file


Arsenal ver 2.0

A free, public-domain group of utilities
designed to make batch files more capable.

by Bill Reamy

This archive should contain the following files:

AllSet.exe Like the Dos 'Set' command.
DiskSize.exe Reports (in ErrorLevel) the size of a disk.
FileFits.exe Checks the size of a particular file.
FileSize.exe Reports (in ErrorLevel) the size of a file.
Input.exe Places user input in an environment variable.
IsExt.exe Checks a file's extension against a list of extensions.
IsReady.exe Reports (in ErrorLevel) on the readiness of a drive.
JustName.exe Strips file extensions from filenames. Simulates user pressing the PrintScreen key.
RandFile.exe Selects a file at random.
Selector.exe A point & shoot file picker.
Buba.doc This Documentation.

If you want a quick help screen for any of these programs, just run the
program with just ? as a parameter. For example: FileFits ?

* DISCLAIMER: These programs are provided as is. They seem to work on my *
* system without causing damage. I do NOT guarantee they will do the same *
* on your system. I haven't (can't) tested these programs with all versions *
* of DOS, and I can't guarantee they won't lock up your computer, destroy *
* data or make you impotent or anything like that. But I would like to hear *
* about any problems you have. *

If you have comments, suggestions, questions, or (gasp) complaints, you
can E-mail me at either of these addresses:
GEnie Mail: W.Reamy
CompServe: 71660,3072
Or, if you prefer real paper (paper, what's that?), drop me a line at:
Bill Reamy
9426 Dubarry Ave.
SeaBrook Md. 20706

The programs in this package are designed to extend, rather than replace
the many fine batch utility packages currently available. You won't find yet
another screen color manipulator here. If you don't yet have a good general
purpose batch file enhancer package, I suggest you look into getting one.
PC Magazine has put out some good utilities in this department, and Peter
Norton has blessed us with some really excellent stuff to add capabilities
and pizzaz to batch files. There are certainly many other good packages, both
commercial and shareware, that can let you harness the power of batch files.

I wrote most of these programs when I was writing a batch file and got
stuck because I didn't have a way of doing a particular task. That's why
the 'U' in BUBA stands for Unique. If anyone has written similar programs,
I am unaware of it. These programs probably won't get used in all (or
even most) of your batch files, but when they are needed, they can prove
to be very valuable indeed.

**** AllSet.exe *************************************************************

AllSet works just like the Dos SET command, except that it
modifies all copies of the enviorment that have enough room.


NOTE: AllSet will not display the Set, as the Dos SET command wil

For more info, see the section 'About Enviorment Variables'
at the end of this file.

**** DiskSize.exe ***********************************************************

DiskSize can let your batch program determine the actual size of a floppy
(or hard) disk. For instance, if you have a 1.2meg 5 1/2" floppy drive, but
the disk currently in it is a 360k floppy, DiskSize can spot it as being 360k.

Usage.......DISKSIZE [d:]
d: is drive you specify, and it is optional.

Returns.....ErrorLevel 1: 360k 5.25"
ErrorLevel 2: 720k 3.5"
ErrorLevel 3: 1.2m 5.25"
ErrorLevel 4: 1.44m 3.5"
ErrorLevel 128: 11-20meg Hard Disk
ErrorLevel 129: 21-40meg Hard Disk
ErrorLevel 130: 41-60meg Hard Disk
ErrorLevel 131: 61-80meg Hard Disk
ErrorLevel 132: 81+ meg Hard Disk
ErrorLevel 255: unknown disk type,
door open,
or other error

NOTE: RamDisks of various sizes may be identified oddly.
For example, a 5 megabyte ram-disk will return ErrorLevel 4.

**** FileFits.exe ************************************************************

FileFits is a utility that reports (in ErrorLevel) on a file's size.
It can be used to determine if a file is to large for a particular
application program before the application is run. It can also be used
to spot empty files, which are sometimes the side-effect of some accident.

usage: FILEFITS file.ext (size)

example: FILEFITS MYFILE.TXT 64000

returns: ErrorLevel = 0 if file size is < or = (size)
ErrorLevel = 1 if file size is > (size)
ErrorLevel = 255 file not found

note: (size) is expressed in bytes, NOT kilobytes.

Most editors won't work with files larger than what will fit in available
memory. Here's a batch file that checks the size of a text file, runs the
editor if possible, or a text file viewer instead. Substitute "EDITOR",
"LISTER", and the trigger file size with names and value appropriate to
what you've got in your system.

Echo Off
if "%1"=="" goto Whoops
FileFits %1 64000
if ErrorLevel 255 goto Whoops
if ErrorLevel 1 goto View
goto End
goto End
Echo !!!ERROR!!!

If you use this example, be sure to substitute the names of the editor and
file viewer you use. The value 64000 should be replaced by a value appropriate
to your system and situation. You may have to experiment to determine this

**** FileSize.exe ********************************************************
FileSize.exe is a utility that reports file size in ErrorLevel.
FileSize can be used by a batch file that displays the rough amount of
time a file will take to send to a modem, or printer. It could also be
used to tell if a file will fit on a small ramdisk, etc.
NOTE: If FileSize returns 0 that does not necessarily mean that the file is
empty! It just means that the file is smaller than 1k. To see if a
file is empty, use FileFits (see above).

Usage: FILESIZE file.ext
Returns: ErrorLevel 0-253: file size in k
ErrorLevel 254: file larger than 253k
ErrorLevel 255: file not found

**** Input.exe ************************************************************
Input.exe is a utility that allows user input in batch programs.
Most user input programs let the user type in a single key, and then
report which key was pressed in ErrorLevel. Input.exe allows the
user to type in an entire line of text, and places this text in an
environment variable. It can be used to get a parameter the user forgot
to enter, or to get a filename, filespec, path or whatever.

NOTE: You MUST read the section of this file called "About Environment
Variables" before using this program.

usage: INPUT envname ["Question or prompt?"]
envname - The name of the Dos Enviorment Variable where
you want Input to store what the user types.
"Question or prompt?" - An optional text string that Input.exe
will display on the same line.

example batch file:
Input Test "Please type in a filename. "
Dir %Test%
Set Test=

With a little clever redirection it can also put other things in environment
variables. For example, the following portion of a batch file will save the
current directory in an environment variable.

rem CD command with no parameters displays current dir.
rem Redirect into Input.
CD | Input OldDir
CD /Data
rem Later on, directory is restored and environment variable is destroyed.
CD %OldDir%
Set OldDir=

**** IsExt.exe ***************************************************************

IsExt tests file's extension, to see if it matches any on a list you give.
The result is reported in ErrorLevel.

usage: IsExt <.ext> <.ext>...

- File name, with extension. Usually you'll use a parameter
(such as %1) or an enviorment variable (such as %Test%).
<.ext> <.ext>... - One or more extensions to test for.

IsExt will return one of the following in ErrorLevel:
0........File given does NOT match any of the extensions given.
1-40.....File given matches extension so-and-so.

if ErrorLevel 255 goto Whoops
if ErrorLevel 5 goto Assemble
if ErrorLevel 4 goto Delete
if ErrorLevel 3 goto RunBat
if ErrorLevel 2 goto Edit
if ErrorLevel 1 goto ReadDoc
if ErrorLevel 0 goto Whoops

IsExt will return 1 if %1 has the extension ".doc", 2 for ".txt", etc.
The batch file can then take the correct action for each file type, or
error condition.

**** IsReady.exe *************************************************************

IsReady reports on wether or not a drive is ready. That is
to say, is it a valid drive, and does it have a disk in it?

Where [d:] can be any valid drive letter. If a
drive is not given, the default drive is assumed.

ErrorLevel is ready
ErrorLevel is Not ready
ErrorLevel 255...invalid paramater(s)

**** JustName.exe ************************************************************

JustName will allow you to seperate a file name from its
extension, and place it into an enviorment variable.

C> JUSTNAME [d:][\path\]

JustName will place the path and name ONLY
( no extension, no ".") in the enviorment variable named.

example batch file:
JustName Source %1
Echo %Source%
MASM %Source%
Set Source=

This program is handy for format conversion batch files, (Arc to Zip, etc.)
or any time you want to change a file's extension.
Echo Off
Rem Converts Arc into Zip
Arc x %1 .\TMP$$
JustName FileName %1
PKZip %FileName%.Zip TMP$$\*.*
Echo Y | Del TMP$$\*.* >Nul
Set FileName=

The above example will expand the arcfile given in %1
(i.e.: C:\> A2Z MYFILE.ARC ), into a temporary sub-directory.
It then zips them, deletes them, and removes the directory.

The line: Echo Y | Del TMP$$\*.* >Nul deletes the files in the temporary
directory, bypassing and hiding the question "Are you sure?".

**** ************************************************************

PrntScrn will simulate the user having pressed the PrintScreen key.
That is to say, it will trigger the print-screen routine in the rom bios.

By the way, this program is only four bytes long.

**** RandFile.exe ************************************************************

Give RandFile a filespec, and it will select a matching file at random.


RandFile will pick one file (at random) that matches the filespec given,
and place its name in the Dos enviorment variable named by EnvVar.

For example:
The above example will run "PLAYVOC", with the name of one of
the *.VOC files in the current directory.

The optional /P switch will cause RandFile to give a full path instead
of just a name. If you use /P, the enviorment variable must be larger.

**** Selector.exe ************************************************************

Selector.exe is a point and shoot file picker for batch programs.
It can provide an easy to use, point and shoot menu from which
the user can select a file. The name ONLY (no path) is then placed
in an environment variable. Be SURE to read the section on at the end
of this file called "About Environment Variables" before using Selector.

Usage: SELECTOR envname filespec1 [filespec2...] ["The Title"] [/M] [/F color]
envname - The name of the enviorment variable that Selector
will use to store the name of the file selected by
the user. Example:
The batch program shown above will type the text
file that the user selects. Be sure to get rid of
the enviorment variable when you are done with it.
filespec - The type of files Selector will display to the user.
For example: *.txt
You can use as many filespecs as you want, just
seperate them with spaces.
title - Optional title that Selector will display.
It must be enclosed by quotes ("").
Switches can come anywhere in the command line in any order.
/M.............Use Mouse
/F 'color'...Foreground color
/B 'color'...Background color
Colors are: Black, Blue, Green, Cyan
Red, Magenta, Yellow, & White
For example: SELECTOR ENV *.* "Pick a File" /F WHITE /B BLUE
This example uses white text on blue background

Selector will allow the user to abort by pressing the ESC key.
If this happens, Selector will not modify the environment variable,
and will return an ErrorLevel of 1. This will also happen if no
files matching any of the filespecs given are found.

Selector will clear the screen after it does it's thing,
so you don't have to worry about it yourself.

*** About Environment Variables *********************************************

The Dos Environment (or Set) is an area of limited size where Dos stores
information in environment variables. Each variable takes the form:
NAME=One or More Words
Here are some examples:
PARA=/d+ /s- /f

Some applications allow you to set parameters using an environment variable
instead of the command line. Dos itself uses three environment variables.
These are COMSPEC, PATH, and PROMPT. You __MUST NOT__ use these names for
your own variables. Comspec is where Dos stores the location of
so it can re-load it when necessary. Path and Prompt are where Dos stores
the search path and current prompt settings.

You can create, change and view your own variables using the Dos Set command.
To view the set of all variables just type SET at the C> prompt. To change
a variable type SET NAME=Whatever. The variable NAME will now be set to
Whatever. IMPORTANT: Do NOT leave a space between the environment
variable name and the "=". For example:
RIGHT: Set Test=Qwerty
WRONG: Set Test =Qwerty
To destroy an environment variable type: Set Name=
Be sure you don't type anything after the "=", not even a space.

The environment is only so big, and if you put a lot of stuff in it, you
may run out of space. If you are using Dos version 3.2 or later, you can
set the size of your environment by putting the line:
in your Config.sys file. Be SURE to replace C:\ with the proper path to, and replace 512 with whatever size (in bytes) environment you
would like to have.

One odd thing about the environment set is that every Com and Exe program
gets it's own copy of the environment. This way, if a program modifies it's
own copy, the master copy is not changed. The drawback to this approach is
that you can wind up with several copies of the environment.

Since Input, Selector, etc. aren't sure which copies to change, they change
all copies of the environment. This can be confusing because it is contrary
to normal practice.

If you use Selector, Input, etc. in a batch file that will be run from inside
of an application program, you may find that the environment has shrunk
to a size that just barely large enough to hold the amount of stuff already
in it. To cure this problem, create the environment variable before you run
the application. You might even want to create a generic environment variable
in your AutoExec.bat file, so that you'll always have it ready to go.

 December 17, 2017  Add comments

Leave a Reply