The magazine of the Melbourne PC User Group

Bats in My Belfry
Dave Mitchell

0ne of the great joys of learning more and more about your computer is creating your own programs. "Creating your own programs?" you say "That's too far down the track for me, I barely know where the ON switch is". Not so, there is a variety of ways you can automate movement around your system by writing wonderful little programs called Batch Files.

Batch Files, as their name may suggest, are Files that contain Batches of DOS commands that are performed one after another and therefore can cut down on the amount of instructions that you have to type at the DOS prompt.

Batch File names always end with the extension .BAT and are the last type of command file looked for by DOS, after .EXE and .COM files.

For example let's say you use Norton Disk Doctor and Norton Speed Disk fairly frequently to check your hard drive and defragment it before you shut off your computer at night. Instead of typing in all the commands to do this one at a time you could write a file called SHUT.BAT to do it all for you.

After these lines you may like to insert a little message with the echo command, e.g.

ECHO "I want to go to bed now so turn me off!"

This will print this on the screen and then you now that your computer is tired and needs a rest.

All you have to type is SHUT and the whole operation is done for you.
SHUT.BAT

CD \NU  
NDD /COMPLETE  
SPEEDISK C : /F 
CLS 


(changes the current directory to the Norton directory)
(runs Disk Doctor without requiring any input from you)
(runs Speedisk again without requiring input) 
(clears the screen)

Another advantage of writing Batch Files is that you can cut down on your PATH command in your AUTOEXEC.BAT (another batch file in your C:\ directory which I deleted twice before I figured out maybe I needed it) by placing all the little .BAT files in a directory called BELFRY (or whatever - it just amuses me to have BATS in my BELFRY) and having this in your PATH command instead of every possible path in your system. This saves on memory, in fact, both yours and your computer's.

Warning. Don't give your .BAT files the same name as an .EXE or .COM file-DOS will look at those two types first and all your efforts will be wasted. Also write your .BAT files in plain text (more gooblede-gook you say?). What I mean is don't use, say Windows Write or WordPerfect or something, use EDIT.COM as it writes in plain text. The others put in special codes and DOS doesn't recognise them.

Anyway the best part of this is that you can tell all your friends that you're a computer programmer now, because you are. The satisfaction you get from making the rotten thing do what you want, with just a quick flurry of your typing finger, is well worth the effort.

Reprinted from the November 1993 issue of PC Update, the magazine of Melbourne PC User Group, Australia

[About Melbourne PC User Group]