cd command (Windows / CMD)
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 / option | Meaning |
|---|---|
| /D | Change 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.
Related commands
- dirList files and subdirectories with names, dates, sizes, and attributes.
- Set-LocationChange the current location to a path in a PowerShell provider.
- mkdirCreate a directory and any missing intermediate directories.
- lsList directory entries and inspect file metadata.
- cdChange the shell's current working directory.
- findWalk directory trees and select entries using tests and actions.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
- rmRemove files and directory trees permanently.
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.