Home > Commands A-M > Commands Ch-Cz

# CHDIR (CD)

Description | Syntax | Parameters | Switches | Related | Notes | Examples | Errorlevels | Availability

Displays the name of the current directory or changes the current directory.

Syntax

CHDIR /?

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

Display the current directory name of a specified drive:

CHDIR drive:

Display the current drive letter and directory name:

CHDIR

or

CD

Parameters
drive: (v2.0 Win95 NT3.5)
Specifies the drive location (if other than the current drive) to which you want to change.
path (v2.0 Win95 NT3.5)
Specifies the directory to which you want to change.
A path of .. specifies you want to change to the parent directory.
A path of ..\.. specifies you want to change to the grand-parent directory.
A path of \ specifies you want to change to the root directory.

Switches
/? (NTXP)
Display help.
/D (NT3.5)
Change the current DRIVE in addition to changing folder.

Related

You can also change directory using the PUSHD command.
Equivalent Linux BASH commands:
cd - Change Directory

pwd - Print Working Directory

Notes
Changing to the root directory

The root directory is the top of the directory hierarchy for a drive. To return to the root directory, type:

```    CD \
```

Using the current directory from a different drive

If you are working in the \PUBLIC\JONES directory on drive C and you change to drive D, you can copy files to and from the \PUBLIC\JONES directory by specifying only the drive letter C:.

Changing the directory on another drive

You can change the current directory on another drive by specifying the drive letter on the command-line when you use CHDIR or CD.

Convert to correct case (Command Extensions)

The current directory string is converted to use the correct CASE. So CD C:\wiNnt would actually set the current directory to C:\Winnt.

Space part of pathname, not a delimiter (Command Extensions)

CD does not treat spaces as delimiters, so it is possible to CD into a subfolder name that contains a space without surrounding the name with quotes: cd \My folder is the same as: cd "\My folder"

Asterisk completes pathname (Command Extensions)

An asterisk can be used to complete a folder name: CD pro* will move to: C:\Program Files

Note: that the syntax above requires a space - after the CD and before the foldername.

Tab Completion

Tab Completion is disabled by default (it has been known to create difficulty when using a batch script to process text files that contain TAB characters). This allows changing current folder by entering part of the path and pressing TAB. CD Prog [PRESS TAB] Will go to C:\Program Files\

Tab Completion is turned on by setting the registry value:

```    REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"CompletionChar"=dword:00000009
```

Examples

Moving down the folder tree with a full path reference to the ROOT folder:

```    CD \winnt\java
```

Moving down the folder tree with a reference RELATIVE to the current folder:

```    CD java
```

Moving up and down the folder tree in one command:

```    CD ..\system32
```

Either of these commands changes your current directory to the directory named PRIMETIM:

```    CHDIR \PRIMETIM
CD \PRIMETIM
```

Suppose you have a directory named SPECIALS with a subdirectory named SPONSORS. To change your current directory to \SPECIALS\SPONSORS, type:

```    CD \SPECIALS\SPONSORS
```

Or, if your current directory is \SPECIALS, you can use to change to the \SPECIALS\SPONSORS directory:

```    CD SPONSORS
```

To change from a subdirectory back to the parent directory, type:

```    CD ..
```

To display the name of the current directory, you can use CHDIR or CD without a parameter. For example, if your current directory is \PUBLIC\JONES on the disk in drive B, type CHDIR to see:

```    B:\PUBLIC\JONES
```

If you are working on drive D and you want to copy all files in the \PUBLIC\JONES and \PUBLIC\LEWIS directories on drive C to the root directory on drive D, type:

```    CHDIR C:\PUBLIC\JONES
COPY C:*.* D:\
CHDIR C:\PUBLIC\LEWIS
COPY C:*.* D:\
```

If, instead, you want to copy all files in the \PUBLIC\JONES and \PUBLIC\LEWIS directories to your current location on drive D, type:

```    CHDIR C:\PUBLIC\JONES
COPY C:*.* D:
CHDIR C:\PUBLIC\LEWIS
COPY C:*.* D:
```

Changing the Current drive, simply enter the drive letter colon:

```    E:
```

To change drive and directory at the same time, use CD with the /D switch:

```    CHDIR /D E:\utils
```

Errorlevels

none.

Availability
External
DOS
v2.0 v2.01 v2.05 v2.10 v2.11 v2.11R v2.12 v2.2 v2.25 v3.0 v3.20 v3.05 v3.1 v3.21 v3.25 v3.30 v3.3A v3.3R v3.3T v3.31 v3.40 v4.0 v4.01 v4.01A v5.0 v5.0A v5.00.02 v5.001A v5.01 v5.02 v6.0 v6.10 v6.2 v6.21 v6.22 v6.23 v7.00 v7.0R1 v7.10 v8.00
Windows
Win95 Win98 WinME
Windows NT
NT3.5 NT4 NT2000 NTXP NT2003