CHDIR (CD)

The description below is from the book
DOS the Easy Way by Everett Murdock Ph.D.

CLICK HERE for information about downloading the book.

Type: Internal (2.0 and later)

Syntax:

CHDIR (CD) [d:]path
CHDIR (CD)[..]

Purpose: Displays working (current) directory and/or changes to a different directory.

Discussion

Used to change from one directory to another you specify. The command can be used without the drive designator (d:) if you were changing to a different directory on the current drive. The path designator can indicate a subdirectory within another directory or subdirectory, but it must not exceed 63 characters in length. The command followed by two periods (CD..) can be used to change to the parent directory.

Enter CHDIR or CD without a drive and path designation to get a display of the current directory.

For more information on CHDIR and other hard disk commands, see Chapter 3, Using Fixed Disks, in the downloadable book DOS the Easy Way .

Examples

To demonstrate how the CHDIR command accesses the DOS directory structure, assume that two directories, WORDS and FILES have been created on a disk. These two directories are to be found within the root directory. Assume also that an additional directory, LETTERS is to be found within the WORDS directory.

To change to the directory LETTERS (that is within the directory WORDS) on the root directory of drive C, enter

cd\words\letters

The command indicates the path sequentially down through the directory path: the first backslash indicates the root directory, down through the directory WORDS, down to the target directory LETTERS.

If you are already working in the WORDS directory, you can change back to the root directory simply by entering

cd\

To change to a directory path other than through the root directory, do not enter the leading backslash. For example, if you are working in the WORDS directory, you can change to the LETTERS directory without going through the root directory by entering

cd letters

A shortcut method to change to the directory immediately above the current directory allows you to enter the CHDIR command followed by two periods. For example, to change from the LETTERS directory to its parent directory, WORDS, enter

cd..

Enter it again to change to the next higher directory (in this case, the root directory).



Back to the Easy DOS Command Index