This is by no means a complete description of these commands, nor is it a
list of all MS-DOS commands. More detailed information can be found at
http://www.computerhope.com/msdos.htm.
See also the pages on batch files and
DOS variables.
A drive is specified by a single letter followed by a colon.
Usually, C: refers to the primary hard
drive, A: is the "floppy" drive,
and E: is the CD-ROM drive.
Each drive has a root directory, which might contain
(sub)directories. Each directory consists of a list of
filenames, or subdirectories, or both. Directory names follow the same
conventions as filenames (see the next paragraph), separated by
backslashes "\". For example,
\ specifies the root directory of the
current drive,
C:\WINDOWS\SYSTEM is the WINDOWS\SYSTEM subdirectory of the
root directory of drive C:, and DATA is
the DATA subdirectory of
the current directory.
A filename consists of up to eight letters or numbers (no
spaces), optionally followed by a period and an extension with
up to three characters. Any filename can be optionally preceded by a
drive letter and/or a directory. Note: Some punctuation marks are allowed in
file names, but others are not. If you must use something other than
numbers or letters, other valid characters are:
( ) { } - _ ! @ # $ % ^ & ` '
A wildcard is a pattern that matches one or more filenames. A
"?" will match any single character, while "*" matches any sequence
of characters. For example, *.txt
matches all files with the extension "txt", ab*.* matches all files whose names begin
with "ab", and ab??.? matches all
files whose name consists of "ab" followed by exactly two more
letters and a one-letter extension.
Where filespec appears below, it can be replaced by either a
filename or a wildcard.
- dir [/options] [filespec]
By itself, shows a listing of all files and subdirectories in the
current directory. If a filespec is given, only that
file (or those files) will be listed.
- md directory-name
Creates a subdirectory.
- cd directory-name
Changes the current directory.
- rd directory-name
Removes (deletes) the specified directory. This command fails if the
directory is not empty.
- copy filename1
filename2
Makes a copy of filename1. If
filename2 already exists, you will prompted to confirm
that you want to overwrite its contents.
- copy filespec
drive/directory
Makes a copy of the file(s) in the
new location (drive or directory), with the same name(s) as the
original(s).
- move ...
Operates in a similar manner as copy, except that the original file is
deleted.
- move directory1 directory2
Rename a directory.
- ren filename1 filename2
Changes a file's name.
- del filespec
Deletes the file(s).
- type filename
Displays the contents of the file on the screen.
- more filename
Displays the contents of the file on the screen, pausing when the
screen is full.
- echo text
Displays the given text on the screen.
- pause
Displays "Press any key to continue" and waits until a key is pressed.
-
command > filename
Sends the output of command (which would ordinarily be sent
to the screen) to the specified file. If the file already contains data,
it is lost.
-
command >> filename
Sends the output of command (which would ordinarily be sent
to the screen) to the specified file. If the file already contains data,
the new text is appended to the end.
-
command < filename
Processes the given command using input (which would otherwise come from the
keyboard) from the specified file. Note: Entering
pause < filename, where filename is
empty (contains no data) will "freeze" DOS, since the computer will never receive the
keypress it is waiting for.
-
command1 | command2
Takes the output of command1 (which would ordinarily be sent
to the screen) and uses it as the input for command2.