how to change directory using Windows command line
Categories:
Mastering Directory Navigation in Windows Command Line

Learn the essential commands and techniques for changing directories efficiently in the Windows Command Prompt (CMD). This guide covers basic navigation, drive changes, and advanced tips.
Navigating the file system is a fundamental skill for anyone working with the Windows command line. Whether you're a developer, system administrator, or just a power user, understanding how to change directories (folders) quickly and effectively can significantly boost your productivity. This article will walk you through the core commands and best practices for directory navigation in the Windows Command Prompt (CMD).
The CD
Command: Your Primary Navigation Tool
The CD
command, short for Change Directory, is the most frequently used command for moving between folders. It allows you to specify a new path, either relative to your current location or an absolute path from the root of the drive.
CD [drive:][path]
Basic syntax for the CD
command.
CHDIR
as an alias for CD
. Both commands perform the same function.Navigating with Relative and Absolute Paths
Understanding the difference between relative and absolute paths is crucial for efficient navigation.
- Absolute Path: An absolute path specifies the complete location of a directory from the root of the drive (e.g.,
C:\Users\YourName\Documents
). - Relative Path: A relative path specifies the location of a directory in relation to your current working directory (e.g.,
CD MyFolder
ifMyFolder
is inside your current directory).
flowchart TD A[Start in C:\Users\YourName] B[CD Documents] --> C[Current: C:\Users\YourName\Documents] D[CD ..] --> E[Current: C:\Users\YourName] F[CD C:\Program Files] --> G[Current: C:\Program Files] A --> B C --> D E --> F
Flowchart illustrating relative and absolute path navigation.
REM Navigate to a subfolder
CD MyDocuments
REM Navigate up one level
CD ..
REM Navigate to the root of the current drive
CD \
REM Navigate to a specific absolute path
CD C:\Program Files\Microsoft VS Code
Examples of using CD
with relative and absolute paths.
Changing Drives
The CD
command alone cannot change drives. To switch to a different drive (e.g., from C:
to D:
), you simply type the drive letter followed by a colon.
D:
CD MyProjectFolder
Changing to the D: drive and then navigating to a folder.
/D
switch with CD
. This is particularly useful when scripting.CD /D D:\MyProjectFolder
Changing drive and directory in a single command.
Useful Shortcuts and Tips
Here are some additional tips and shortcuts to make your command line navigation even faster:
- Tab Completion: Start typing a directory name and press the
Tab
key to auto-complete the name. PressTab
repeatedly to cycle through matching directories. - Quoting Paths with Spaces: If a directory name contains spaces, you must enclose the entire path in double quotes.
CD /?
for Help: To get a full list ofCD
command options and their descriptions, typeCD /?
and press Enter.
CD "Program Files"
CD "My Documents with Spaces"
Using double quotes for paths containing spaces.
1. Open Command Prompt
Press Win + R
, type cmd
, and press Enter, or search for "Command Prompt" in the Start Menu.
2. Check Current Directory
Type CD
and press Enter to display your current working directory.
3. Navigate to a Specific Folder
Use CD
followed by the path. For example, CD C:\Users\Public\Downloads
.
4. Change to a Different Drive
Type the drive letter followed by a colon, e.g., D:
.
5. Explore with Tab Completion
Start typing a folder name and press Tab
to quickly complete it.