HOME
TOPICS
ABOUT ME
MAIL

 
How batch files work under DOS, and how to make some simple ones without knowing anything special about computers. Part 2.
  technofile
Al Fasoldt's reviews and commentaries, continuously available online since 1983

Batch files for newcomers, Part 2


By Al Fasoldt
Copyright © 1990, The Syracuse Newspapers

   There's an amazing power inside your IBM-compatible computer. It's not in your neighbor's Macintosh, and it's not in most other home computers.
   It's called the batch file language. Don't worry -- it's all in English, and it's easy to use. In fact, it's so easy to use that many of you already use it without even knowing it.
   All a batch file does is repeat your keystrokes every time you run it -- that is, every time you type the name of the batch file and then press the "return" or "enter" key.
   Simple, right? It sure is. And it's powerful, too.
   And best of all, it's fast and it doesn't make mistakes -- assuming, of course, that you type things into the batch file correctly the first time.
   Batch files must follow two simple rules. First, they have to be written in regular text, called ASCII. No word-processor codes allowed, although you can go ahead and use your word processor as long as you save the batch file in text (Wordstar calls it "non-document") or ASCII mode. Second, the filename for a batch file must end with ".BAT" (and the period, by the way, has to come before the last three letters).
   What good are batch files? Since they do the typing for you, they can be long and complicated. And since you can name the batch file itself something short and sweet, your work is as easy as -- well, as easy as A, B, or C.
   If you use an IBM-compatible computer or a small computer such as an Apple, a Commodore or an Atari, you spend a lot of your time giving commands.
   I don't mean you're being bossy. I'm talking about the way your computer works.
   You give it instructions by means of a command line. When you see a prompt on your screen, you type a command. Usually, that command is gibberish to everyone except the computer literati. It could easily look something like this: "ARC E SPIFFY B:\BIGFILE."
   Commands are necessary evils, in a way. Programmers know this, so they sometimes write their own little additions to the operating system.
   Most of these are in the form of utilities -- small programs that work on a PC just as special tools work for a carpenter. Without them, computer users like you and me would have a hard time doing little tasks.
   Here's an example. MS-DOS, the computer's operating system, lets you read a file when you enter the command "TYPE" and the name of the text file.
   Nice, right?
   Wrong. The text runs right off your screen. There's an added MS-DOS command called "MORE" that stops the text with each screenful -- all you have to do is add it to the "TYPE" command -- after the end of the name of the file, which makes no sense at all. And, wait a second, don't forget to type a vertical bar symbol before you type "MORE."
   Got it? I say forget it. So does Vern Buerg, who created a wonderful utility called "LIST." It is such a good replacement for all sorts of file-reading and file-copying activities within DOS that anyone who works with a PC would be crazy not to use LIST.
   There are plenty of other examples -- formatting utilities, file-movement utilities, disc-checking utilities. If you are frustrated with MS-DOS, programs such as these can make your life a lot easier.
   That's just one side of the good news. And there's more. One thing DOS has is flexibility -- a whole batch of flexibility.