Dos - Cd (CHDIR) - (Current|Working) directory

> Procedural Languages > Dos (Win32 Shell Scripting) and Utilities

1 - About

Cd is a command that:

  • displays the name of the current directory.
  • or changes the current directory.

More: the online help can be read by typing:

cd /?

3 - Syntax

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


  • .. is the parent directory.
  • the D switch change the current drive in addition to changing the current directory for a drive.

4 - How to

4.1 - display the current directory

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


4.2 - get the current directory


5 - Command Extensions

If Command Extensions are enabled CHDIR changes as follows:

5.1 - Path case

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

5.2 - Spaces are not delimiters

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

cd \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.

lang/dos/cd.txt ยท Last modified: 2018/09/19 13:10 by gerardnico