The Silly Software Company (logo) Silly Software Company
-=oOo=-


A poor man's way of doing things
is still a way to get things done

Bat File Technology

This page is about Bat File Technology. Bat File Technology is an ancient technique, from between the stone and iron ages, when bat bones, teeth, skeletons were filed into precision instruments of which the world famous Neanderthal Razor Blade is a splendid example. Later on, the term was used for an ancient technique to automate computer actions.

In the old days, personal computers worked with DOS. Where windows allows the user to point, click, drag, drop, ... files on his computer and see what he's doing, DOS was command driven. This means you actually had to tell it what to do. This was done by typing commands at the 'command prompt'. This feature is still visible in windows (see DOS prompt, startmenu|run).

to copy a file called myfile.txt from a diskette (A:-drive) to the hard drive (C:), you'd type

c\> copy myfile.txt a: c:

When typing commands, you had to be very careful about spelling and syntax, or DOS would reply "Bad command or file name". It would never reply 'Excellent command !" or "Beautiful file name ...". It would not even tell you what was so bad about your command or filename.

This could become very annoying, especially when you had to use a long series of complicated commands, in the right order, and each with a specific set of options.

This problem was solved with the invention of the bat file. This was not a tool to shape or sharpen bat bones or bat teeth, but a file, like a text file, that listed all these commands with the correct spelling and options, in the right order. (batch : list, set, collection, ... )

When this text file was saved with the extension '.bat', DOS would recognize it as a set of commands, and bring all the commands to the command prompt, one by one, exactly the way they were written down, simply by typing the file name of the bat file, pretty much like typing a single command.

Because these series of commands were written down, there suddenly was a possibility to introduce some elementary 'programming', by introducing conditions: IF this or that is like so and so, THEN do this (and in all other cases, do something else). Often the 'do this' or do 'that' would be a GOTO (Bat language for 'go to'), which allows skipping 1 or more commands.

Some interactivity with the user was made possible with the commands ECHO, to put text on the screen, and CHOICE, to have a question appear on the screen, and let the user answer - usually [Y]es or [N]o Depending on the user's choice, the bat file would then continue one way or another, e.g. skip a few unnecessary commands, terminate, CALL another bat file or start a program, etc.

Finally, DOS allowed the use of (environment) variables in bat files, which made the bat language more flexible, using values put in by the user before running the bat file rather than have all these values included in the bat file itself.

eg SET user=John would replace the word 'user' in the batch file with the text 'John', so that it could be used for personalized greetings the command ECHO hello user would put the text "hello John" on the screen

So starting from a simple batch of commands, bat file technology can be used for rather real programming - with nothing else than the operating system already present on your computer.

An excellent example of bat file technology is Bare Bones e-mail for DOS, a bat file that, using DOS commands in combination with one or two freeware programs, allows you to read, write, send and receive e-mail.