Using the Windows Console

A primer for new users of SNDAN

Launching a Console Session.
DOS commands
Console Properties
Running programs
System PATH and Environment variables
Batch Files

It is not practical to attempt a full tutorial here on Windows Console commands (formerly known as MSDOS). This page summarises the essential commands and techniques, to enable you to get started with SNDAN and, maybe, develop a taste for what can be a very fast way of working. It is intended primarily for those who haev notused a Console window before.


There is a number of equivalently meaning terms used to refer to a Console window. It may be a 'DOS session' or a 'DOS window' (where DOS may also be 'MSDOS'), a 'terminal window,' the term most used in Unix systems such as Linux, a 'command-line window', or a 'command shell' (from the notion that it acts as a safe and convenient 'shell' around the Operating System's main commands). All these terms mean essentially the same thing, which is called here a "Console window".

There is one linguistic difference. Windows Explorer (and Windows documentation generally) refers to files and 'Folders'. The latter is supposed to be a 'friendly' word. In a Console session, however, the older term 'directory' is still more widely used, and is the basis of many of the command names.

Launching A Console Session.

The Windows Console is available from the Start Button on the Taskbar; it is called 'Command Prompt' or 'MSDOS Prompt' depending on the OS; the almost undecipherable icon actually contains the letters of "MSDOS". Click on the menu, and a Console window will appear.

Click on the menu again, and another console will appear. Each window represents an individual 'session'; they can work entirely independently, and even be configured independently. On the last displayed line of text  you will see a little flashing line - a cursor. This is the 'command prompt' itself. When you type characters, you see them at the cursor point. Don't press <Enter> while you try this out - you may inadvertently do something undesirable! The Enter key gives the command  'do it', just as it does most of the time in a Windows GUI application. Having typed a few random characters, press the Escape key to clear the prompt.

DOS Commands.

There is one command you can enter safely, and which will set up something vey useful (if it is not already set up, of course).


This sets up a 'command history', and the ability to edit  command lines and reuse them. At any time, while following the descriptions ahead, you can use the up-arrow and down-arrow keys to step through old commands. Whichever is visible is a viable command line awaiting  <Enter>. Doskey is one of the magic tools that makes command line  work much more comfortable than many people expect.

The command prompt may appear something like this:


You may recognize this as a 'path' - the Windows directory on Drive C, in this case. Now, find a directory containing some of your soundfiles, using the Windows Explorer. Does the title bar of Explorer display the 'full path' of whatever directory you are in? If not, you need to change the settings for Explorer to make it do so. You will need this so that wherever you go using Explorer, you can see the full path in the title bar. In Windows 9x, go to the View->Options menu. In Windows NT or Windows2000, go to Tools->"Folder Options" and select the View tab. Activate the option 'Show full MSDOS path in title bar'. Now, whenever you navigate to a new folder in Explorer, you can see the exact path to type in Console window to get to the same place.

Using Explorer, go to the drive and folder where you have installed SNDAN. Let us say that the path is D:\sndan.
Go to the 'examples' folder, using Explorer. The 'full path' changes to D:\SNDAN\EXAMPLES\. So you can see that each level of a directory is indicated by a slash. Now, return to the DOS console. If it has a different root drive from the one SNDAN is installed in, you need to change drive before you can do anythng else. All you have to do is type the letter of the new drive, followed by a colon, followed by <Enter>,  thus.


the console prompt immediately changes. The root directory of drive D:  is now your new 'current directory'. From here you want to go to the SNDAN folder, so you need to change directory:

cd sndan\examples <enter>

With cd you can go up and down directory levels very quickly. Two dots together signifies 'up a level'. So if, having done the above command, you now type

cd ..

you will find that you have gone 'up' to the sndan directory. Type the command


to see a listing of everything in this directory.

Now, use doskey (up-arrow) to get that command back, and presss <Enter>. You have now gone back up to the top level, where you started. Now use doskey again, using up-arrow twice. This recalls the original cd instruction, to get to the 'examples' folder.


cd and dir are the commands you will use most often. Some directories contain a lot of files, and it can be difficult to see them all sometimes. One unusual but very useful solution is to use output redirection. For example, if you want to print a list of all the files in a particular directory, change to it using the cd command (change drive first if necessary), and type the following command:

dir > dirlist.txt

This writes everything that would  be written to the screen to the text file "dirlist.txt" instead. You can examine it at your leisure, print it out, and even send it an email message. Also, you can send it to another program, it that program is designed to receive it. this is called 'input redirection'. For example, you can send the output of dir to the command more:

C:\WINDOWS>dir | more

This pauses the screen output at each screenful, so that you can read it all. press the spacebar to scroll the next screenful, or <Enter> to get one more line. Finally, you can redirect a file of text into a program. This depends on the program expecting user input from the keyboard (e.g in response to prompts). The addsyn programs in SNDAN can do this, for example. The text file must contain eactly the input epected by the program. Input redirection uses the < character, followed by the textfile name; it is used right at the end of the command line for the program being used:

addsyn1 -i  infile outfile < myparams.txt

For another way of seeing a lot of screen output, see Console Properties .


To see only files of a particular type, you can use the * wildcard symbol. This means 'anything'. So if you type:

dir *.wav

you are asking for a listing of all the files with the .wav extension. This wildcard system is very powerful, as it means you can run one command, that acts on a large number of files. How often have you needed to delete old soundfiles, or old text files, and carefully selected each one in Explorer (perhaps using the CTRL key method to select several), then finally pressing delete? With the single DOS command

del *.wav

you will delete ALL the .wav files in your current directory. Use with care!

This is relevant to SNDAN, as all graphics output is achived by creating  graphics files with  the extension .eps. These can accumulate rapidly, and probably you will want to delete all of them at the end of a session. The command

del *.eps

will do this much more quickly than can ever be done using the mouse. If you want to keep some of the files, there is trick. Don't try this now unless you actually have some files to delete!

All the graphics files created by SNDAN start with the letters g_raph....., followed by a random set of numbers. These are 'temporary' filenames created automatically by Windows, and are guaranteed to be unique each time. To keep a file, rename it to something else, but keeping the .eps extension, of course. For example, to keep the file g_raph001234.eps, rename it to 'waveimage.eps':

ren g_raph001234.eps waveimage.eps

Now, remove the remainder with this command:

del g_raph*.eps

This deletes only the files with names starting g_raph; the new file is quite safe.

There are many more commands that the few described here. You can type 'help' at the prompt to get a list of all the commands available. To get details of any particular command, type 'help' followed by the command name, to get full usage information. Try it with the dir command:

help dir

You will see the command has a few extra features!

Console properties.

Ther are serveral ways of customizing the appearance of the Console window: number of lines displayd, number of characters per line, font, and so on. Depending on your operating System (Windows9x, NT, Window2000) you may be able to click directly on a 'Properties' Toolbar Button, or, if there is no toolbar, right-click on the title bar to bring up a context menu.

Experiment with the properties, until you find an appearance that suits you. The 'traditional' size for a DOS window is 25 lines of 80 characters. Needless to say, this is unnecessarily restrictive. Yu will notide that you can set both th windwo sie and the intenal buffer size independently. When the internal buffer is larger than the physical size (which can happen when you resize it they way you resize any window), the Console window becomes scrollable. this is a facility long enjoyed by Unix users, but is still a relative novelty for MDSOS users. Some SNDAN commands can print a great deal of text to the Console, and without the ability to define a larger internal buffer (200 lines say), combined with with vertical (and even horzontal) scrolling, most of this text will be lost for ever.

Running programs using the Console.

There are two basic type of Windows program. The most familiar is of course the GUI application, such as Word, Notepad, MediaPlayer, and your favourite MIDI sequencer. The other is a 'Console Application', or what is often simply called 'command line program'. The difference in fact is that the latter is exclusively text-based, does not create an application window, and support a 'message loop' responding to mouse control (this is a simplification; it is possible with the right programming to use teh mouse in a DOS session). However, even GUI programs use a command line. You can in fact launch GUI applications from the DOS console. For example, once your Console winodow has appeared, just  type


(and press <Enter>, of course).

As you will see, this launches Notepad. In principle you can launch any GUI application this way. Notepad uses a command line. try this:

notepad test.txt

Notepad launches, and opens the file if it exists; otherwise, it asks if you want to create it.

Now try something else:

mplayer /play  tenor.wav

This launches MediaPlayer, and plays the requested file. You have given mplayer two command line 'arguments'. The first is an optional command to play the sound immediately, the second is the name of the file to play. part of teh power of teh command line environment comes from the ability to supply a number of different arguments (or 'parameters' if they are numbers)
(This assumes MediaPlayer is installed,  which it almost certainly will be.)

The system PATH and Environment Variables

Hwever, to be able to run a program, DOS must be able to find it. If the program is not itself in your current directory, it must be in one of the directories listed on the system PATH. You can find out what these are by using the command 'path'. Depending on what software you have installed, this path can amount to quite a long list. The Windows system directories wll certainly be there, as may be many others. Any unusual ones may hev been added by instructions in the AUTOEXEC.BAT file in the root directory of drive C. This file runs DOS commands automatically, including the command 'set', whch assigns a text string to a name. In this case the whole path list is assigned to the name PATH. Many programs define their own special symbols; by typing the command 'set' by itself, you get a list of everything defined when the machine was booted.

Command line programs such as those in SNDAN often rely on just such 'environment variables'. More importanly, if you want to be able to run SNDAN programs from within any directory (which you will), you will need to add the full path of the directory where they are stored, to the system PATH. The best way is to edit AUTOEXEC.BAT, and add the new path to the end of the existing one. Alternatively, you can copy all the programs to a directory that is already listed, perhaps C:\UTILS if it exists.
If you edit the PATH list, note that each path in the list is separated from the next by a semi-colon. You will need to adhere to the rule carefully.

Batch Files

Finally, note that AUTOEXEC.BAT is a batch file. This is simply a file with text commands, that can be 'run' just as a program is run. Instead of typing a long command directly at the DOS prompt, type it into a text file, give that file a name with a .bat extension, and run it by typing the filename. Make sure it does not have the same name as a program in your current directory, or on the PATH. Batch files are great for automating a sequence of commands, or simply for running a single complex command with many arguments. They are nothing like as powerful as unix shell scripts can be (which can amount to quite complex programs in their own right), but can do quite a lot nevertheless.

You can use command line arguments with a batch file. These are counted from one, by the command processor, and can be accessed within the batch file using a % prefix.  Here is a simple but useful example, based on the MediaPlayer example above. Open notepad, or any other preferred text editor, and type one line:

mplayer /play  %1.wav

Save this as "play.bat". You  run this like any DOS program, with a single argument, the name of a wave file without the .wav extension (it is filled in by the batch file). Saves a little typing!

Two questions are left as an exercise for the reader. What happens if you forget to give play.bat the filename argument? How could the batch file catch the error?

[SNDAN home page]