Explanation, syntax, and examples of using common DOS internal commands. Includes usage of: TIME, DATE, CLS, DIR, COPY, TYPE, DEL, REN, RD, MD, CD, PATH, and SET PROMPT.
These DOS commands are called internal commands because their code is included in COMMAND.COM, the DOS and Windows 9x command processor. Since COMMAND.COM is loaded into primary memory when DOS or Windows 9x is booted, the internal commands are always in memory and can be executed any time without first being fetched from disk (secondary memory).
This is in contrast to the disk-bound external commands, which reside only in secondary memory until the moment they are needed. Then they are loaded into primary memory by the operating system, but only if the OS can find the program on disk.
The syntax for frequently used DOS internal commands follows.
TIME
DATE
CLS
DIR [d:][path]
Optional switches:
/p Display dir info and pauses display when the screen is full
/w Display names and extensions only in five columns
To display a file directory listing for D:\DATA\LETTER\ANNUAL from
different current directories:
D:\DATA\LETTER\ANNUAL> DIR
D:\DATA> DIR LETTER\ANNUAL
C:\WINDOWS> DIR D:\DATA\LETTER\ANNUAL
COPY [d:][path][name.ext] [d:][path][name.ext]
Optional switches:
/v Verify, copies the file and compares it with the original
/b Binary file
To copy a file from D:\BATCH to the root of A: drive
A:\> COPY D:\BATCH\CL.BAT (from A: drive)
D:\BATCH> COPY CL.BAT A:\ (from D:\BATCH)
To copy a file from the root of C: to A: drive and change its name
A:\> COPY C:\MSDOS.SYS MSDOSSYS.BAK (from A:)
C:\> COPY MSDOS.SYS A:\MSDOSSYS.BAK (from the root of C:)
To copy all of the files from the root of A: to D:\CCV\ENGCOMP
A:\> COPY *.* D:\CCV\ENGCOMP (from A:)
D:\CCV\ENGCOMP> COPY *.* A:\ (from D:\CCV\ENGCOMP)
TYPE [d:][path][name.ext]
To display the contents of the file MY.LET to the screen
A:\> TYPE MY.LET
DEL [d:][path][name.ext]
To delete one file:
A:\> DEL A:\MY.LET
To del all files in current directory
A:\> DEL *.*
REN [d:][path][name.ext] [d:][path][newname.ext]
To change the name of the file D:\LET\ANNUAL\99.DOC to 1999.DOC
D:\LET> REN ANNUAL\99.DOC 1999.DOC (from D:\LET)
D:\DATA> REN \LET\ANNUAL\99.DOC 1999.DOC (from D:\DATA)
C:\WINDOWS> REN D:\LET\ANNUAL\99.DOC 1999.DOC (from C:\WINDOWS)
MD [d:][path][dirname]
To create a directory named HERMIT in the root of D: drive
D:\> MD HERMIT (from D:\)
C:\> MD D:\HERMIT (from C:\)
RD [d:][path][dirname]
To remove the HERMIT sub-directory:
D:\> RD HERMIT (from D:\)
C:\> RD D:\HERMIT (from C:\)
CD [path][dirname]
To make D:\HERMIT the current directory
D:\> CD HERMIT (from D:\)
D:\DATA> CD \HERMIT (from D:\DATA)
D:\DATA\SOURCE> CD \HERMIT (from D:\DATA\SOURCE)
D:\DATA\SOURCE> CD .. (from D:\DATA\SOURCE)
PATH=[path;path;...]
To set the DOS PATH:
PATH=C:\DOS;C:\PCW;\C:\BIN
To display the current path:
PATH
SET PROMPT=[metastring] (from the command line)
PROMPT=[metastring] (in a batch file)
Metastrings are combinations of DOS PROMPT characters
DOS PROMPT Character | Resulting prompt |
$b | | |
$e | (EOF marker) |
$h | destructive bk space erases >, so just blinking cursor |
$n | default drive |
$q | = |
$v | DOS version no |
$$ | the $ sign |
$d | system date |
$g | > |
$i | < |
$p | full path description |
$t | system time |
$p$_ | full path description, skips line (_ = CR and LF) |
Examples (from command line)
To make the prompt display the current drive & current path followed by >
SET PROMPT=$P$G
To have the prompt display the current date, time, and drive on separate lines
SET PROMPT= $D$_$T$_$N$G