Classic Computer Magazine Archive COMPUTE! ISSUE 168 / SEPTEMBER 1994 / PAGE 14

Doskey makes DOS fly. (command line editor) (Introdos) (Column)
by Tony Roberts

Doskey is a command line editor that's included with DOS 5 and above. If you don't have Doskey installed and you do any work at all at the DOS prompt, you're missing out on an incredible tool.

Simply type doskey to install the program or, better yet, include the command DOSKEY/INSERT (to turn off over-strike) in your AUTOEXEC.BAT file.

To use Doskey, press the up- and down-arrow keys to move through a list of previously issued DOS commands. When you find one you want to reissue, just press Enter.

Have you ever made a typo while entering a long path and filename? When DOS tells you it can't find the file you've specified, just press the up-arrow key to recall the bad command, and then use the left-and right-arrow keys to move to your typo. Make the correction and press Enter again, and your command will executed without any further difficulty.

Although command line retrieving and editing are Doskey's most useful features, this program has other tricks up its sleeve.

Doskey also permits the creation of DOS macros which can be loaded into memory and executed as required. One of the provisions of the macro feature makes a useful command line resource: issuing multiple commands on a single command line.

Let's look at how a macro is created. The following line creates a macro we'll call Tidyup. This macro copies all of the DOC files in the current subdirectory to another subdirectory for safekeeping; then it removes all the BAK files from the current subdirectory.


C:\SAFETY [paragraph] DEL *.BAK

Executing this command creates a new command called Tidyup, which will carry out both the copy and the delete functions at the same time. This command will stay in memory until Doskey is turned off or the computer is reset. Note the paragraph symbol [paragraph] that separates the two commands. This symbol, entered using the key combination Ctrl-T, is used to tell where one command ends and another begins.

Even if you don't use Doskey to create macros, you can use the Ctrl-T separator to enter several commands on a single command line. I often pop out of Windows and use this feature when I need to perform a series of time-consuming tasks. For example, a couple of times a week, I need to download several large PostScript files to my laser printer for proofing. Since these files usually are 2MB-3MB in size, this process can take a while. Then I compress the PostScript files into archives that fit on a single floppy disk.

To handle this chore, I use the Ctrl-T separator to enter all of the necessary commands onto one command line; then I can go to lunch or to a meeting, leaving the computer to handle the work while I'm away. The command I use looks something like this.




If you ever find yourself waiting for your DOS prompt to come back, try using this feature to issue all of your commands at once.

Another interesting feature of Doskey is that you can use its command line history function to create a batch file from a series of commands you've just issued.

Batch files are quick and simple, but if you've ever written one, you know how easy it is to leave out a step. Using Doskey ensures that commands will be entered in the correct sequence.

Let's say you've just stepped through a complicated series of commands to perform a function and you realize that you're going to have to repeat that function regularly. Perhaps this is a monthly or quarterly routine that you'd like to automate.

You can view your entire Doskey command line history by typing doskey/history. You can capture that same history to a file; redirect the output to a file by typing doskey / history > routine.bat.

Once the command line history has been captured in a file, use the DOS Edit program or another text editor to edit out any unwanted commands in the text file, including the last line, which will be the command you issued to create the batch file.

Before you save your batch file and put it away until you need it next quarter, be sure to add some documentation so that you can remind yourself how, and under what conditions, to execute the program. Do this by adding a few REM statements to the file. Any line in a batch file that begins with REM is considered to be a remark and will not be executed by the computer.

If you know ahead of time that you're going to want to capture a series of commands from the Doskey history to a batch file, press Alt-F7 before you begin. This clears the Doskey history buffer so you can start your recording with a clean slate.