Microsoft DOS cd command

Updated: 11/13/2018 by Computer Hope

About cd

CD (Change Directory) is a command used to switch directories in MS-DOS and the Windows command line.

Availability

The CD command is an internal command and is available in the below Microsoft operating systems.

Syntax

Windows XP and later syntax

CHDIR [/D] [drive:][path]
CHDIR [..]
CD [/D] [drive:][path]
CD [..]

.. Specifies that you want to change to the parent directory.

Type CD drive: to display the current directory in the specified drive.
Type CD without parameters to display the current drive and directory.

Use the /D switch to change current drive in addition to changing current directory for a drive.

If Command Extensions are enabled CHDIR changes as follows:

The current directory string is converted to use the same case as the on disk names. So CD C:\TEMP would set the current directory to C:\Temp if that is the case on disk.

CHDIR command does not treat spaces as delimiters, to CD into a subdirectory name that contains a space without surrounding the name with quotes. For example:

chdir \winnt\profiles\username\programs\start menu

is the same as:

cd "\winnt\profiles\username\programs\start menu"

which is what you would have to type if extensions were disabled.

Windows 98 and earlier syntax

CHDIR [drive:][path]
CHDIR[..]
CD [drive:][path]
CD[..]

Cd examples

cd\

Goes to the highest level (the root) of the drive.

cd..

Moves back one directory. For example, if you are in the C:\Windows\COMMAND> directory and type the above command it would take you to C:\Windows> directory.

Tip: With Windows 95 and later versions of Windows you can go back more than one directory when using more than two periods. For example, typing cd... (three periods) would take you back two directories (if possible) instead of only one directory.

cd Windows

If this directory is available in the current directory, it will take you into the Windows directory. The directory name "Windows" can be substituted with any other directory name and in MS-DOS and the Windows command line capitalization is not important.

Tip: If at any time you need to see what directories are available in the directory you're currently in, use the dir command.

cd\windows

If this directory is available, it would first move back to the root of the drive and then go into the Windows directory. The C:\Windows directory is the default install directory, so on almost all computers this directory should be valid.

cd\windows\system32

If this directory is available, it will move into the system32 directory, a subdirectory of the Windows directory.

cd /d e:\pics

If for example, you were on the C: drive, typing the above command with the /d option would first switch the E: drive letter and then move into the pics directory.

cd

Typing cd alone will print the working directory. For example, if you're in c:\windows> and you type the cd it will print "c:\windows." For those users who are familiar with Unix or Linux, this could be thought of as doing the pwd (print working directory) command.