You may also need to use this system, for example, when changing your password, and you can enter DOS by choosing 'MS-DOS Prompt' from the Windows 95 Start menu.
G:\>
Commands may be typed in upper or lower case. Here, they are specified in upper case to distinguish them from other input.
Commands have a particular format. Some can be used simply by typing the command name only, as in:
DIR
which displays a listing of files in the current directory.
COPY filea fileb
In this case, filea would be the name of a file to copy from and fileb would be the name of a file to copy to.
Parameters can sometimes be omitted in which case a default action will apply.
DIR
DIR /W
DIR /P
result in listings presented in a different format as detailed later.
Some Useful DOS Commands
COPY original-file destination-file
where original-file and destination-file are file names, separated by a space.
The command can be used to merge several files into one file since the original-file parameter can be a list of filenames separated by the + symbol. For example:
COPY file1 + file2 file3
would copy file1 and file2 into file3.
Note that the file names used in the copy command must include the file extension if it exists. So if you were copying a fortran program called first.for, for example, you would need to include the .for extension in the filename.
DEL filename
where filename is the name of the file to be deleted. You are asked to confirm that you really want to delete the file. Note that the name must include the file extension.
The amount of space on a disk is limited and it is necessary periodically to tidy up unwanted files. It is possible to use a '*' character in a filename to match any sequence of characters. This feature is very useful when deleting unwanted files with identical extensions. For example, when developing programs,
DEL *.obj
will delete every binary (.obj) file in the current directory. Since an .obj file can always be recreated from the original source program, it is usually unnecessary to keep it.
If used without options this command will give a list of files in the current directory, including any extension (e.g. .for), and their size.
If used with the option /P, that is:
DIR /P
The same information will be displayed page by page with the message:
strike a key when ready
at the end of each page.
If it is used with the /W option, i.e.
DIR /W
the listing is of names and extensions only and in a more compact format across the page.
It is very important to have a second copy of your programs and data in case you lose your disk or it becomes unreadable for some reason. Use the DISKCOPY command as follows:
DISKCOPY A: A:
where A: denotes the drive the disks will be loaded into. When a copy of your disk is generated in the computer's memory, the computer tells you to remove the first or source disk and insert the disk, which is to become the copy (the target disk).
Insert the target disk and press ENTER. If the second disk is not formatted it will be formatted automatically. The source disk should be write protected using the tab in the corner in case you mistake it for the target disk (see the chapter on using disks).
LIST filename
where filename is the file to be printed. If the printer is busy, or if you don't need a printed copy, you can use the TYPE command to view a file on the screen.
You could also use an editor such as DOS Edit to display a file, in which case, as a bonus, you would then be in a position to correct any errors you might notice. Remember that the file name must include the file extension. So if you want to print your Pascal program called first you would need to use:
LIST first.pas
REN oldname newname
where oldname is the file to be renamed and newname is the name it is to be given.
Note that files on drives other than the current drive can be referred to by prefixing the filename by the relevant drive letter, for example:
A:\filename
where the \ refers to the ‘root’ directory of the drive.
Filenames can also include directories separated by the \ character as in:
A:\dir1\dir2\filename
TYPE filename
where filename is the name of the file to be displayed on the monitor screen. If you are looking at a long file, you will need to press the PAUSE key to stop continuous scrolling. Press the space bar to continue scrolling when you have read the screen.
FORMAT A:
Note that by default the disk will be formatted to hold about 1.44 megabytes of data.
Warning: formatting will destroy any data on the disk so only do this once!
‘cwd’ stands for ‘Current Working Directory’.
DOS Conventions
DOS commands are not case sensitive. Some commands have switches; these must be preceded by a forward slash (/). Pathnames may be preceded by a drive letter as in ‘X:pathname’ and if no drive or pathname is given the current directory is assumed.
The Commands
/4 - use double rather than
high density (40 tracks)
/8 - use 8 sectors of each
track
/n:xx - specifies xx
sectors per track
/t:yy - specifies yy
tracks
/v - prompt for volume label,
up to 11 characters
/f:720 - format at 720
kb
Characters (each prefixed by
$) mean:
$=$, t=time, d=date, p=cwd,
v=version, n=drive,
g=>, l=<, b=!, _=CRLF,
s=leading space, e=ESC (for ANSI driver)
/f:nbytes - nbytes per file,
need about 20 bytes per file, default 2048
/l:nlocks - nlocks per file,
default 20
/a!m - if archive bit set !
also clears in source
/d:date- modified on or after
date only
/s!e - copy subdirectories
if not empty ! even if empty
/p - prompt
/v - verify
/w - wait for
keypress
The template is accessed by the following keys:-
F1 - get next character from
template
F2 C - get characters up to
but excluding character C
F3 - get remaining characters
from template
del - skip one character in
template
F4 C - skip characters up to
but excluding character C
ESC - clear command
line
INS - toggle overwriting of
template
F5 - copy command to template
for re-editing
F6 - put ^Z in new
template
The arrow keys may also be
used to recall the previous command.
Arguments for batch files are accessed as ‘%1’ to ‘%9’.
may be negated by NOT before condition
\ = root directory or a
directory separator
. = current directory
.. = parent
directory
Wildcard characters may be
used in filenames or extensions:
? = any character
* = any tail or
extension
X: - switches to current
working directory (cwd) on drive X.
^C - abort current
command
^H - destructive
backspace
^J - linefeed - physical
newline to input long lines
^N - toggle copying of
terminal output to printer
^P - toggle redirection of
terminal output to printer
^S - suspend/restart terminal
output
^X - cancel current line, and
output \-CR-LF
^Z - end of
file
> send output
to...
>> append output
to...
< take input
from...
| pipe output to next
input
For example:
pipe output from command a to
input of command b:
command a | command
b
send a directory listing to
file filename:
DIR > filename
EDIT (filename)
The editor provides pull-down menus, operated by the keyboard or mouse, and a help facility. Note that any changes made to a file overwrites the original, no backup is created.