Skip to main content

Command referencecd

cd command (Windows / CMD)

WindowsCMDfilebeginner

What it does

Display or change the current directory in Command Prompt. Searches for the cd command cmd windows usually need CMD syntax, practical switches, and notes on how it compares with PowerShell or Linux alternatives. This page covers syntax, common options, and copyable examples for Command Prompt.

Display or change the current directory in Command Prompt.

Syntax

cd [/D] [drive:][path]

Common options

Flag / optionMeaning
/DChange both drive and directory.
..Move to the parent directory.
\Move to the current drive root.
.Refer to the current directory.

Practical examples

Open project

cd C:\Projects\site

Changes folder when already on drive C.

Change drive too

cd /D D:\Backups

Switches drive and directory together.

Go upward

cd ..

Moves one directory level up.

Linux ↔ Windows equivalent

Closest match: cd (Linux / bash / sh / zsh). Change the shell's current working directory.

Common mistakes

  • Omitting `/D` when changing to a path on another drive.
  • Failing to quote a path containing spaces.

FAQ

What does cd do in Command Prompt?

Display or change the current directory in Command Prompt.

How do I run cd in CMD?

Open Command Prompt and follow `cd [/D] [drive:][path]`; quote paths containing spaces.

What is a practical cd example in CMD?

Try `cd C:\Projects\site` — Changes folder when already on drive C.

Can cd be used in a batch file?

Yes. Check its exit code and escape CMD metacharacters when input is variable.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.