Learning how to change directory in Command Prompt is essential for anyone working with Windows. The process is simple: type cd followed by the folder path you want to access, then press Enter. This basic command lets you navigate your computer’s file system quickly without clicking through folders.
Command Prompt remains one of the most powerful tools in Windows, even in 2026. While graphical interfaces are convenient, knowing how to move between directories using commands gives you speed, precision, and access to advanced features that point-and-click can’t match.
What Is the CD Command?
The cd command stands for “change directory.” It’s your navigation tool in Command Prompt, letting you move from one folder to another anywhere on your computer.
Think of it like this: your computer’s folders are rooms in a house. The cd command is how you walk from one room to another. Without it, you’re stuck in whatever folder Command Prompt opens in by default.
Why You Need to Know This
You might need to change directories to:
- Run programs that aren’t in your system PATH
- Access files in specific folders
- Execute scripts stored in particular locations
- Install software that requires command-line setup
- Troubleshoot system issues
- Work with development tools and programming environments
How to Open Command Prompt
Before you can change directories, you need to open Command Prompt.
Windows 10 and 11:
- Press
Windows + Rto open the Run dialog - Type
cmdand press Enter
Alternative methods:
- Right-click the Start button and select “Command Prompt” or “Terminal”
- Search for “cmd” in the Windows search box
- Press
Windows + Xand choose Command Prompt from the menu
When Command Prompt opens, you’ll see a black window with white text showing your current location, usually something like C:\Users\YourName>.

Basic CD Command Syntax
The basic format is straightforward:
cd [directory path]
The directory path can be written in two ways: absolute or relative.
Absolute Paths
An absolute path includes the complete location starting from the drive letter:
cd C:\Users\John\Documents
This command takes you directly to the Documents folder, regardless of where you currently are.
Relative Paths
A relative path starts from your current location:
cd Documents
This only works if the Documents folder exists inside your current directory.
Step-by-Step: Changing to a Different Folder
Let’s say you’re in C:\Users\John and want to move to C:\Users\John\Documents\Projects.
Method 1: Using the full path
cd C:\Users\John\Documents\Projects
Press Enter. Your prompt now shows C:\Users\John\Documents\Projects>.
Method 2: Moving step by step
cd Documents
cd Projects
Each command moves you one level deeper.
Method 3: Single command with relative path
cd Documents\Projects
This moves through multiple folders in one step.
Changing to a Different Drive
Here’s something that confuses many people: the cd command alone won’t switch drives.
If you’re on C: drive and type:
cd D:\Files
Command Prompt changes the working directory for D: drive, but you stay on C: drive. To actually switch to D: drive, you need an additional step.
The correct way to change drives:
D:
Just type the drive letter followed by a colon, then press Enter. Now you’re on the D: drive.
Or use the /d switch:
cd /d D:\Files
The /d parameter tells Command Prompt to change both the drive and directory at once.
Moving Up Directory Levels
To go back to a parent folder, use two periods:
cd ..
This moves you up one level. If you’re in C:\Users\John\Documents, this command takes you to C:\Users\John.
Moving up multiple levels:
cd ..\..
Each .. separated by a backslash moves you up one additional level.
Going directly to the root:
cd \
This takes you to the root of the current drive, regardless of how deep you are in the folder structure.
Working with Folder Names That Have Spaces
Spaces in folder names require special handling. You have two options:
Option 1: Use quotation marks
cd "C:\Program Files\Adobe"
The quotes tell Command Prompt to treat the entire path as one unit.
Option 2: Use the tilde and number format
cd C:\PROGRA~1\Adobe
Windows creates short names for folders with spaces. PROGRA~1 is the short name for “Program Files.” You can see these short names using the dir /x command.
Quotation marks are simpler and more reliable. Use them whenever you’re dealing with spaces.
Useful CD Command Variations
Return to Your Home Directory
cd %USERPROFILE%
This takes you to C:\Users\YourName from anywhere on your system.
Go to the Windows Directory
cd %WINDIR%
This navigates to your Windows installation folder, typically C:\Windows.
Display Current Directory
cd
Type cd without any path and press Enter. Command Prompt shows your current location without changing it.
Change Directory and List Contents
cd Documents && dir
The && operator runs multiple commands in sequence. This changes to Documents and immediately lists its contents.
Common Mistakes and How to Fix Them
Mistake 1: Forgetting the Drive Switch
Wrong:
cd D:\Projects
(When you’re on C: drive, this doesn’t actually move you to D:)
Right:
cd /d D:\Projects
Or:
D:
cd Projects
Mistake 2: Mixing Forward and Back Slashes
Wrong:
cd C:/Users/John/Documents
Right:
cd C:\Users\John\Documents
Windows uses backslashes (), not forward slashes (/). While some commands accept forward slashes, stick with backslashes for consistency.
Mistake 3: Not Handling Spaces
Wrong:
cd C:\Program Files
(Command Prompt interprets this as cd C:\Program with “Files” as a separate parameter)
Right:
cd "C:\Program Files"
Mistake 4: Typing the Full Path for Relative Navigation
If you’re already in C:\Users\John and want to go to C:\Users\John\Documents, you don’t need the full path.
Inefficient:
cd C:\Users\John\Documents
Efficient:
cd Documents
Advanced Directory Navigation Techniques
Using Tab Completion
Start typing a folder name and press Tab. Command Prompt automatically completes it. Press Tab multiple times to cycle through options.
Example: In C:\Users, type cd Do and press Tab. It completes to Documents if that folder exists.
This works with full paths too:
cd C:\Prog[Tab]
Completes to cd "C:\Program Files" or cycles through folders starting with “Prog.”
The PUSHD and POPD Commands
These commands create a directory stack, letting you jump between locations quickly.
PUSHD saves your current location and moves to a new one:
pushd C:\Users\John\Documents
POPD returns to the saved location:
popd
This is incredibly useful when you need to temporarily work in a different directory and then return to where you were.
Example workflow:
C:\Projects> pushd D:\Backup
D:\Backup> [do some work here]
D:\Backup> popd
C:\Projects>
You can stack multiple locations. Each pushd adds to the stack, and each popd removes the most recent one.
Creating Custom Shortcuts with DOSKEY
DOSKEY lets you create command aliases. Set up shortcuts for directories you visit frequently.
doskey proj=cd C:\Users\John\Projects\Active
doskey docs=cd C:\Users\John\Documents
Now typing proj takes you directly to your Projects folder.
These aliases only last for your current Command Prompt session. To make them permanent, add the DOSKEY commands to a batch file and run it automatically when Command Prompt starts.
Practical Examples for Real Situations
Example 1: Running a Python Script in a Specific Folder
Your script is at D:\Code\Python\data_analysis.py.
cd /d D:\Code\Python
python data_analysis.py
The first line switches to D: drive and changes to the Python folder. The second line runs the script.
Example 2: Navigating to a Network Drive
cd /d \\ServerName\SharedFolder\Projects
The /d switch works with network paths too. This takes you to a shared folder on your network.
Example 3: Accessing Program Files for Troubleshooting
cd "C:\Program Files\Mozilla Firefox"
firefox.exe -safe-mode
This navigates to Firefox’s installation folder and launches it in safe mode.
Example 4: Working with Deep Folder Structures
You need to access C:\Users\John\AppData\Local\Temp\BuildOutput\Release\x64.
Instead of typing the whole path:
cd %LOCALAPPDATA%\Temp\BuildOutput\Release\x64
The %LOCALAPPDATA% environment variable expands to C:\Users\John\AppData\Local, saving you typing.
Combining CD with Other Commands
Search for Files in a Specific Directory
cd Documents
dir /s *.pdf
Changes to Documents, then searches all subdirectories for PDF files.
Copy Files After Navigation
cd /d D:\Backup
copy C:\Important\*.docx .
Moves to D:\Backup, then copies all DOCX files from C:\Important to the current directory (represented by the dot).
Create a New Folder and Enter It
mkdir NewProject && cd NewProject
Creates a folder called NewProject and immediately changes into it.
Troubleshooting Common Issues
“The System Cannot Find the Path Specified”
This error means the path doesn’t exist or is typed incorrectly.
Solutions:
- Double-check spelling and capitalization (usually doesn’t matter in Windows, but verify anyway)
- Verify the folder actually exists using File Explorer
- Make sure you’re using backslashes, not forward slashes
- Check if you need quotation marks for spaces
- Confirm you’re on the correct drive
“Access Is Denied”
You’re trying to access a folder that requires administrator privileges.
Solution:
Close Command Prompt and reopen it as Administrator:
- Search for “cmd” in the Start menu
- Right-click Command Prompt
- Select “Run as administrator”
Path Too Long
Windows has a 260-character limit for paths (though this has been relaxed in recent versions).
Solutions:
- Navigate in smaller steps instead of using one long absolute path
- Use shorter folder names
- Enable long path support in Windows 10/11 through Group Policy or Registry settings
- Use the
SUBSTcommand to map a long path to a drive letter
Can’t Change to Network Drive
Solution:
Map the network location to a drive letter first:
net use Z: \\ServerName\ShareName
Z:
Or use the UNC path with /d:
cd /d \\ServerName\ShareName
Environment Variables for Directory Navigation
Environment variables provide shortcuts to common locations. Here are the most useful ones:
| Variable | Typical Path | Use |
|---|---|---|
| %USERPROFILE% | C:\Users\YourName | Your user folder |
| %APPDATA% | C:\Users\YourName\AppData\Roaming | Application data |
| %LOCALAPPDATA% | C:\Users\YourName\AppData\Local | Local application data |
| %PROGRAMFILES% | C:\Program Files | 64-bit programs |
| %PROGRAMFILES(X86)% | C:\Program Files (x86) | 32-bit programs on 64-bit Windows |
| %WINDIR% | C:\Windows | Windows installation |
| %TEMP% | C:\Users\YourName\AppData\Local\Temp | Temporary files |
| %HOMEDRIVE% | C: | Your system drive |
Using environment variables:
cd %APPDATA%\Microsoft
cd %TEMP%
cd %PROGRAMFILES%\Adobe
This makes your commands work on any Windows computer, regardless of username or custom Windows installation locations.
Batch Files for Repeated Navigation
If you frequently navigate to the same set of directories for a project, create a batch file.
Create a text file called goto_project.bat with:
@echo off
cd /d D:\Work\CurrentProject\src
echo Now in project source directory
dir /b
Save it anywhere in your PATH, or in a folder you’ll remember. Double-click it or type its name in Command Prompt to instantly navigate to your project and see a file list.
For more complex projects, you can create menu-driven batch files that let you choose which directory to visit.
Comparison: CD vs Other Navigation Methods
File Explorer:
- Pros: Visual, intuitive, good for browsing
- Cons: Slower for precise navigation, requires mouse clicks
CD Command:
- Pros: Fast, precise, scriptable, works remotely
- Cons: Requires memorizing paths, less visual
PowerShell’s Set-Location:
- Works identically to CD in most cases
- PowerShell offers more advanced path manipulation features
- Good to know both if you work across different Windows environments
For quick, repeated navigation to specific locations, the CD command beats clicking through File Explorer windows. For exploring unfamiliar directory structures, File Explorer’s visual approach helps you understand the layout.
Security Considerations
Be careful when changing to directories you don’t recognize, especially when:
Running downloaded batch files:
Check the contents before execution. A batch file could change to a directory and run malicious code.
Using paths from untrusted sources:
Verify the path exists and is safe before navigating to it.
Working with system directories:
Changing to system folders like C:\Windows\System32 while running as Administrator gives you power to accidentally damage your Windows installation.
Network paths:
Only navigate to network locations you trust. Malicious network shares can contain harmful files.
Quick Reference Table
| Task | Command |
|---|---|
| Change to specific folder | cd C:\Folder\Path |
| Change drive | D: or cd /d D:\Path |
| Move up one level | cd .. |
| Move up two levels | cd ..\.. |
| Go to root of current drive | cd \ |
| Go to your user folder | cd %USERPROFILE% |
| Show current directory | cd |
| Handle spaces in names | cd "C:\Folder Name" |
| Save current location | pushd C:\Path |
| Return to saved location | popd |
| Change and list files | cd Path && dir |
Frequently Asked Questions
How do I change directory to D drive in Command Prompt?
Type D: and press Enter to switch to the D drive. If you want to go to a specific folder on D drive in one step, use cd /d D:\FolderName. The /d parameter changes both the drive and directory together.
Why does CD not change to another drive?
The CD command changes your working directory on a drive, but it doesn’t actually switch drives. This is by design in Windows. You must type the drive letter followed by a colon (like D:) to switch drives, or use cd /d to change drive and directory simultaneously.
Can I use forward slashes instead of backslashes?
While some Windows commands accept forward slashes, you should use backslashes with the CD command. Windows uses backslashes as the standard path separator, and using forward slashes can cause unexpected behavior in some situations.
How do I go back to the previous directory?
Use cd .. to move up one level to the parent directory. If you want to return to a directory you were in earlier, use the pushd command before leaving it, then use popd to return. There’s no built-in “back” button like in File Explorer unless you use this stack approach.
What does cd\ do versus cd..?
cd\ takes you to the root directory of your current drive (like C:), while cd.. moves you up one level to the parent folder. If you’re in C:\Users\John\Documents, cd\ takes you to C:\ but cd.. takes you to C:\Users\John.
Conclusion
Changing directories in Command Prompt is a fundamental skill that makes you more efficient on Windows. The basic cd command is simple, but understanding its variations, switches, and related commands like pushd and environment variables transforms you from someone who struggles with command-line navigation to someone who moves through the file system faster than point-and-click users.
Remember these key points:
- Use
cdfollowed by the path to change directories - Add
/dwhen switching drives - Use quotation marks for paths with spaces
- Press Tab to autocomplete folder names
- Combine
cdwith&&to run multiple commands - Leverage environment variables for consistent navigation
Practice these commands regularly. Within a few sessions, navigating through Command Prompt will feel natural. You’ll find yourself opening CMD instead of File Explorer for tasks that require precision and speed.
