Batch Utilities for DOS

Back to Front Page

global menu:



Notes: Under construction. This page is primarily devoted to batch utils that enhance / supplement the DOS batch language. No attempt has been made to be exhaustive. Batch purists and hackers often avoid these helpers. But sometimes 3rd party utils can help the rest of us solve those (apparently) intractable problems more quickly than using raw brain power alone <g>. Most of the utils below were developed exclusively for DOS and may not operate as expected under Win9x and/or NT. A very big thanks to Howard Schwartz who suggested and commented on many of the programs on this page.

An incomplete list of Batch resources on the Web:


IF


ERR2ENV- Set current errorlevel to an environment parameter.

unrated [added 07-07-99]

"Dos IF statements need a lot enhancing to test for various conditions: err2env.zip is a life saver that lets you store the current error level in an environment variable and/or set it yourself." Author: Zhuhan JIANG, Australia (1994) Home Page.; Suggested by Howard Schwartz.

Syntax:
err2env [/qnàx#+#-#[,envpara]] or
err2env "/<>qnàx#+#-#t#[,envpara]" [fileout [filein] ]
         where # represents an positive integer.

q    - quiet with no non-critical messages
n    - environment parameter ERR_LEVEL will not be changed
x#   - exit with errorlevel specified by #
+#   - exit errorlevel will be the entry errorlevel plus #
-#   - exit errorlevel will be the entry errorlevel minus #
à    - remove stored errorlevel addresses from ERR2ENV.EXE.
,env - set errorlevel to the environement parameter specified
       by "env"

Notes: May not work properly under Win9x (recursive shell failures).

download err2env.zip (18.3K)


TESTIF- Test for system, disk, time, and file conditions in batch files.

unrated [added 07-07-99]

Tests for: VideoMode, VideoPage, ScreenWidth, Year, Month, Day , DayOfWeek, Hour, Minute , Second , WriteVerify, DosVersion, MinorDosVersion, CurrentDrive, Drives, Floppies, SerialPorts, ParellelPorts, CapsLock, NumLock, ScrollLock, MemSize, Random, SectorsPerCluster(n) BytesPerSector(n), FreeClusters(n), TotalClusters(n), FreeSpace(n), TotalSpace(n) , Exist , FileSize , FileAttr , FileDate , Mem(A:B), MemW(A:B), Port(A). Author: Marc Perkel, Computer Tyme Software. (1990); Suggested by Howard Schwartz.

download testif.zip (12K)


TEST- Test for file/directory status in batch files.

unrated [added 07-07-99]

"test evaluates the expression <expression> and, if its value is true, returns a non-zero (true) exit status; otherwise, a zero (false) exit status is returned. test returns a zero if there are no arguments."

Primitive operators testing one file:

Primitive operators comparing two files:

The above operators can be combined with logical (AND, OR) operators.

Author: Jason Mathews. (1994); Suggested by Howard Schwartz.

download test.zip (14K)


SET ENHANCERS

ADVSET

unrated [added 07-07-99]

"Advset lets you delete, append to, prepend to an already existing variable. It also lets you convert values to all caps, all small letters, etc." Author: Kåre Fundal, Denmark (1995) Home Page ; Suggested by Howard Schwartz. Newer ftp://konrad.ruc.dk/pub/kf/advset16.zip is available but is shareware (1997).

download advset14.zip (12K)

ASET

unrated [added 07-07-99]

"ASET lets you store all kinds of information in a variable, and do arithmetic as well (a big lack in batch files)." Author: Richard Breuer, Germany (1993); Suggested by Howard Schwartz.

download aset10.zip (80K)

STRINGS

unrated [added 07-07-99]

"Strings does similar things to ASET, but takes up less memory." Author: Douglas Boling (1995); Suggested by Howard Schwartz.

download string25.zip (75K)


ECHO ENHANCERS


XECHO- Echo replacement useful for batch generation and creating logfiles.

unrated [added 07-07-99]

"The echo command often needs enhancement so you can put any ascii character in a file, or echo something to a file without starting a new line. The latter is handy for building commands in a 2nd batch file, created by a first batch file. XECHO is an enhanced echo that does these things and also lets you echo all kinds of information to the screen. XECHO also allows echoing of redirection symbols." Author: Claus-Juergen Claussen, Germany (1998) Sugg. by Howard Schwartz, others.

download xecho133.zip (84K)


SEND- ECHO enhancer.

unrated [added 09-12-99]

From the docs: "SEND is intended to remedy....defects of ECHO:

  1. It does not terminate line in a CR-LF combination; one can add such a pair "by hand".
  2. Typing "send ^G" is equivalent (except for the lack of a CR-LF) to typing "echo <Ctrl G>" so one need not fill files with control characters.
  3. Typing "send ^[E > prn" will send a <Esc>E to the printer thereby turning on "emphasized" print.
  4. In addition....SEND supports the PROMPT $- characters."

Author: Howard Rumsey and Barry Simon (1985); Sugg. by Howard Schwartz, source: Laurence Soucy's Batfiles: The DOS batch file programming handbook.

download send.zip (12K)


LOGECHO- ECHO enhancer.

see:HORST batch utilities collection.


PAUSE substitutes...

1. HoldIt- PAUSE replacement time-outs after specified time.
2. MPause- PAUSE replacement uses mouse or keys to answer prompt.
3. Press- PAUSE substitute with OK button box, mouse support, time-out option.

  1. HoldIt: * * * Differs from PAUSE in it's ability to timeout after a specified period of time (seconds). HoldIt can also return error level messages. If you use MS-DOS 6+, also look at the CHOICE command which can work in a similar fashion. Author: Peter Strickler, Switzerland (1993).
  2. MPause: * * "If a mouse is detected, then the program waits for any key stroke OR any mouse button press. It prompts you to press any key or mouse button. If no mouse is present, then the action is identical to that of the PAUSE command, including the identical prompt to press any key." Doesn't add a new line after return. Author: C. Somerville. (1992). Also see: PAWS.
  3. PRESS: * * * Yet another replacement for the PAUSE command. By default it darkens the screen and displays an OKAY button box. The only problem with this design is that the box can sometimes obscure potentially important screen text. You can add text to the button box, and also use both ok/cancel buttons with errorlevels for decision branching in batch files. Option to time-out after x seconds. Mouse support too. Author: George Kerber (1995)
  1. download holdit10.zip (7K)
  2. download mpause.zip (3.4K)
  3. download press.zip (30K)


FOR


FORTUNE- Enhanced FOR.

unrated [added 07-07-99 updated 09-04-99]

FORTUNE "extends the functionality of the DOS FOR command by providing ways of splitting up the parts of the file name and manipulating the parts." Translate variables into drive, path, filename root, filename extension, and filename characters. Author: Bruce Guthrie/ Wayne Software; Suggested by Howard Schwartz.

Version history: v908 released 8-99. See Wayne Software

http://www.geocities.com/SiliconValley/Lakes/2414/fortn908.zip (85K)


INPUT


INPUT- Get console input from within a batch file.

unrated [added 07-07-99]

"There are a lot of freeware programs that do what Dos CHOICE does, but better -- getting input from the keyboard. input.zip is an old one (87) I have used for years. It puts whatever you type in a variable, and also lets you set up the prompt so it takes only y/n answers, converts your input to caps, etc. " Author: William C. Parke (1987); Suggested by Howard Schwartz.

download input.zip (3K)


DATE


FDATE (2)- Multi-purpose date manipulation/ format utility for batch files.

unrated [updated 12-06-98]

Fdate is a utility for performing date formatting and date arithmetic in DOS batch files. Includes a variety of means for placing output into environment variables which can be then be manipulated in numerous ways in a batch file. Detailed and brief help documentation included; multiple help screens. This program is admittedly beyond my comprehension- but it is too interesting to ignore. Author: Stephen Ferg (1997).

Features from the documentation:

New in v 96a: minor update for justifying NT text; docs address NT issues.

download fdate96a.zip (85K)


BATCH UTIL COLLECTIONS
(These packages contain a diverse array of utils).


HORST- Batch utility collection.

* * * * * [updated 6-17-98]

Even my limited mind can recognize the diversity, quality, and usefulness of this compilation. From a reader..."All hand-crafted assembler, tiny and incredibly fast. More than a power-users batch toolkit. There is something here for everybody. How can anyone manage without it?" With excellent, separate documentation for each program. Author: Horst Schaeffer, Germany. (1998). Suggested by Robert Bull.

Included programs:

ANSICHK  returns errorlevel 0 if ANSI driver detected
ANSIEX   remove ANSI sequences, emulating cursor movements
ASCREEN  display screen from file, ANSI emulation
BANNER   big font looping message
BIGFONT  display big characters (4 lines high), round pixels
CHOIX    CHOICE clone with mouse support
COUNT    Count, add, subtract (variable), fixed length option
CRC32    report and check CRC32, optional list processing
CRLF     convert: lines to be terminated by CR+LF, CR or LF
CSCRIPT  DEBUG/UU/XXencoded script generator with CRC32
CSOUND   sound output to PC speaker / resident beep replacement
DELAGE   delete/report files by age (days)
DREADY   disk(ette) ready?, optional check "ready to write"?
ESPACE   environment variable space report/check with errorlevel
EVERY    run jobs once a day / on specified days of week
FPATH    locate path of program file, optional CD
INPUT    string input, editing of existing variable..
ISDATE   compare date (also file date, today)
KPUSH    stuff keystrokes into keyboard buffer, code test mode
LINEX    extract [multiple] range of lines from ASCII file
LISTMOD  make list of commands from input list
LOGECHO  custom entries for logfiles, with enhanced date handling
LOGTRIM  trim logfiles (min/max KB)
NSET     pipe data from STDIN into an environmental variable
PACO     executable COM file archive (run with prefix)
PCHECK   checks if (parallel) printer is ready, optional reset
QECHO    "quote echo" with control codes, defaults without CR/LF
RANDOM   random number (given range) to STDOUT
TIMENOW  current time within given period(s)?
WAIT     wait with prompt, key by errorlevel
WAIT4    wait for/until with large "digital clock", options
WHAT     errorlevel for: hour/minute/year/month/day/day of week

update 6-17-98: New programs added: FPATH, TIMENOW. See Home page for other update information.

download horst31.ZIP (68K)


Batchman.- Multi-function batch program.

unrated [added 07-07-99]

Old but packs many batch utils into a single program.

Syntax: BATCHMAN [command] [arguments] [/R]
/R = Display ErrorLevel

CLS [nn]  nn[H]=color H=hex            CECHO [C] [nn,]string  nn=color;C=no CR
SETLOOP n  n=loops (0-255)             DEC  decrements SETLOOP  EL=SETLOOP
QFORMAT [d:] [N] d:=A: or B: N=No ask  BREAK  EL=1 if break ON
PUSHPATH  EL=0 if successful           POPPATH  EL=0 if successful
ANSI  EL=0 if installed                BEEP [m,n[;m,n]...]  m=freq. n=1/18 sec
WAITTIL hh:mm[:ss]                     WAITFOR [mm:]ss
CURSORTYPE m,n  m=start; n=stop line   DRIVEEXIST d:  EL=1 if exist
DIREXIST directory  EL=1 if exist      ISVOL [d:]volume  EL=1 if exist
YEAR  EL=year from 1980 (0-199)        MONTH  EL=(1-12)
DAY   EL=(1-31)                        WEEKDAY  EL=(0-6) Sun=0; Sat=6
HOUR  EL=(0-23)                        MINUTE  EL=(0-59)
SECOND EL=(0-59)                       VIDEOMODE  EL=(0-19)
ROWS  EL=display rows                  COLS  EL=display columns
SETCURSOR m,n  m=row; n=col            E43V50
PRTSC [F]  F=formfeed                  COMPARE string string  EL=0 if match
CANCOPY filespec [d:]  EL=0 if room to copy
WARMBOOT                               COLDBOOT
SHIFT ALT | CTRL  EL=1 if depressed    NUMLOCK [ON | OFF]
CAPSLOCK [ON | OFF]                    SCROLLOCK [ON | OFF]
RENDIR old new  EL=0 if successful     ROMDATE  display BIOS date
GETKEY ['string' n] n=Function key EL=position; EL=scan code if no list
DOSVER  EL=x where x=(major*32)+minor; eg. DOS 3.30=(3*32+30)=126
MAINMEM n | R  main memory;  n=K bytes needed; EL=0 if enough; R=report
EXPMEM n | R  expanded memory          EXTMEM n | R  extended memory

Author: Michael Medford/ PC Mag (1989)

download vol9n02.zip (59K)


Batpower- Old but useful batch util collection.

unrated [added 09-13-99]

This ancient (1984-87) compilation of batch utils (by various authors) contains some gems that still come in handy:

download batpower.zip (40K)

Also see: Another SWEEP util can be found here (incl. a Win32 version).


Batch Compilers


BatLite- Batch file to COM converter.
Bat2Exec- Batch file to COM converter.

unrated [added 09-02-99]

Both of these programs compile a DOS batch file into an executable COM file. One of the principle uses is to speed up execution/display of larger batch files. In addition, certain programs (e.g., LinkLn) won't be able to utilize your batch files unless you convert them to a COM/ EXE format. These programs do have basic limitations and a read of the docs is suggested before converting a more complex batch file.

Bat2Exec: The classic no frills PC Mag utility. Author: Doug Boling (1991).

download bat2ex15.zip (33 K)

BatLite: Less well known but includes documentation of limitations of compiling batch files. ".....has extended commands of its own, creates smaller files, and seems to run faster/better." Free for private use only. Author: Pieter A. Hintjens, Belgium (1992).

download batlit15.zip (23K)

Suggested by H. Schwartz.


MISC BATCH UTILS


"There are many freeware equivalents to the Unix sleep command (wait n seconds before doing the next command." One of these is ftp://ftp.cdrom.com/pub/simtelnet/msdos/batchutl/sleep25.zip ; another is...

SLEEP- Batch util sleeps until event occurrence.

* * * * * [added 3-21-98]

A very flexible command line tool for scheduling events; intended for batch files. "The possible events are: FOR a length of time, TILL a certain time, a question ASKed of the user, certain FILESPECS appear or disappear, the UPS is active, or a SCHEDuled event. Commands can be combined. Sleep is DOS, DesqView (uses DV System Memory), OS/2, and Windows aware.

Usage:
INDIRECT COMMAND FILE.Sleep "@"<file>
FOR syntax............Sleep for [[hh":"]mm":"]ss
TILL syntax...........Sleep till [[hh":"]mm":"]ss
ASK syntax............Sleep ask '<prompt string>' <responses>
FILESPECS syntax......Sleep ["&"]"+"|"-"<filespec> ...
PAR and SER syntax....Sleep par|ser <port adr> <out> "+"<in> "-"<in>
SCHED syntax..........Sleep sched <file>

No documentation- type SLEEP /? for extended help screens. Author: John R. Souvestre (1997)

download sleep_47.zip (33K)


COUNTDN- Launch program after countdown- with keypress abort option.

* * *

From the docs... "This program will launch any specified program (EXE, COM, or BAT) after a countdown of a specified number of seconds. The countdown may be aborted and the program launched immediately by pressing the ENTER key. Pressing the SPACE or ESC key will stop the countdown without launching the program.

This is ESPECIALLY useful for programs that run from the AUTOEXEC.BAT file (like Windows) that you may not want to run EVERY time. This is easier than maintaining multiple configuration files. There are two ways to run COUNTDN: Regular mode and Advanced Mode. The difference is that regular mode is very easy to use, but adds a small amount of memory overhead (3-4 K) to the launched program. Advanced mode is a little more complex to use, but does not take any memory from the launched program." Default countdown beeps can be turned off with /Q switch. Released by David C. Filmer. 1994.

Not as flexible as SLEEP- but more "showy" and easy to use.

download countdn.zip (31K)


Locate- File finder with useful batch creation capability.

"Locate, a file finder, offers some very nice macro/batch features which in combination with simple redirection ( > my.bat), can be used to generate and execute batch files on the found files. Check out both its /O and /B options:"
/O:"string"  macro Output
/C:"string"  run Commands      Either may include:

   &F  fully qualified filename     C:\WINDOWS\WIN.COM
   &D  directory name, canonical    C:\WINDOWS
   &P  directory name with \        C:\WINDOWS\
   &N  filename                     WIN.COM
   &R  filename without extension   WIN
   &X  extension only               COM
   &S  filespec without drive       \WINDOWS\WIN.COM
   &L  drive letter                 C:
   &A  attributes, standard         +A -S -H -R
   &B  attribute bits               A....
   &W  Win95 full LFN               "C:\Directory Name\Long File Name"
   &Z  Win95 LFN, filename only     "Long File Name"
   &T  terminate line
   &&  ampersand    &E  escape    &Q  quote mark
   &1  date         &2  time      &3  file size

To illustrate a most basic application, LOCATE's /O switch can be used as a "wildcard" helper for programs that don't support wildcards. Suppose you wanted to convert a series of *.txt files from DOS to UNIX format but your converter program (let's say DOS2UNIX) doesn't have wildcard support. Locate can easily generate a batch file that contains a DOS2UNIX conversion command for each *.txt file it finds:

LOCATE *.txt /O:"DOS2UNIX < &N > &R.unx" >>CONVERT.BAT

A couple lines from the generated CONVERT.BAT might look like this:
DOS2UNIX < one.txt > one.unx
DOS2UNIX < two.txt > two.unx

For each unique *.txt file found by LOCATE (&N), a new UNIX formatted file will be created with the original file basename (&R) and a new extension defined by the user (e.g., .unx). The advantage of using Locate becomes apparent when you realize that you can filter for very specific file property combinations (filename, attributes, date, time, etc). Hint: Try using LOCATE /O with XECHO commands- lots of possible text processing applications.

See description and link to Locate on File Finders and Identifiers page. Author: Charles Dye; Suggested by B. Simonsen.


RAMBAT- Stores batch files in one file, use in RAM disk.

unrated [added 07-07-99]

"Rambat is an interesting utility that stores all your small batch files in one file, and then puts them all in your ramdisk as single batch files." The purpose of the program is to reclaim wasted disk space allocated to (usually) tiny batch files. (You'll have to be willing to accept the memory penalty imposed by a RAM disk.) Author: Jay E. Morris (1992)

download rambat1.zip (5K)


REXX- (REGINA, BREXX) Powerful alternative to DOS batch.

Although creative geniuses can cajole the DOS batch language into performing near-unthinkable tasks (e.g., math), mere mortals may prefer a less obtuse method of writing command scripts.

REXX is a syntactically comprehensible but powerful procedural language. REXX is different from most other computer languages because it can be used as a macro language for arbitrary applications. REXX can be attractive to the batch user because it explicitly supports many functions absent in DOS batch (e.g., math, dates, data conversion, string and word manipulation, etc.). It also can call external programs, internal operating system commands, and external REXX libraries. If you're not a programmer but can write a DOS batch file, learning the basics of REXX should not be a great challenge. REXX interpreters include a trace /debug mode which aids greatly in troubleshooting scripts. One of the obvious drawbacks of using REXX as a replacement for batch is that it uses additional memory.

Two (unrelated) free REXX interpreters for DOS exist:

REGINA: unrated [added 07-29-99] External dynamic libraries (which greatly extend the functionality of REXX) exist for the Win32 version but are lacking in the DOS versions. Sample scripts included. Author: Mark Hessling, Anders Christensen (1998). See http://www.lightlink.com/hessling/ for latest REGINA DOS executables (32-bit DJGPP or EMX-VCPI packages). Extensive documentation is distributed separately. Packages available for Unix, OS/2 and Win32.

BREXX: unrated [added 07-29-99] is available in both 16 and 32 bit versions (and an 8086 package!). BREXX includes some DOS specific external libraries and several sample scripts. Author: Vassilis N. Vlachoudis, Greece (1999). See http://ftp.gwdg.de:81/pub/languages/rexx/brexx/html/rx.html. Packages are also available for Linux, AIX, and Amiga.


[ Go to Top | Front Page ]

© 1994-1999. Rich Green