To change directories in Command Prompt, use the cd command followed by the path of the folder you want to enter. For example, typing cd C:\Users\YourName\Documents and pressing Enter moves you into the Documents folder. This guide covers the full syntax, common pitfalls, and practical examples for navigating drives and folders in Windows CMD.
What Is the cd Command?
The cd command, short for “change directory,” is one of the oldest and most essential commands in Windows Command Prompt. It tells the shell to switch your current working directory to another location on the same drive or a different drive. The command works in all modern Windows versions, from Windows 7 through Windows 11, and also in PowerShell (though PowerShell has additional aliases like Set-Location).
When you open Command Prompt, you start in your user profile folder (e.g., C:\Users\YourName). The cd command lets you move to any folder you have access to, whether it’s a system folder like C:\Windows or a network path mapped to a drive letter.
Basic Syntax and Usage
The basic syntax is simple:
cd [path]
Where [path] can be an absolute path (starting from the drive root) or a relative path (starting from your current location). Here are the most common forms:
- Move into a subfolder:
cd Documents— moves fromC:\Users\YourNametoC:\Users\YourName\Documents. - Move up one level:
cd ..— goes to the parent folder. - Move to the root of the current drive:
cd \— goes toC:\if you’re on C:. - Move to a specific folder on another drive:
cd /d D:\Projects— the/dswitch changes both the drive and the directory. - Move to a folder with spaces:
cd "C:\Program Files"— always use quotes when the path contains spaces.
If you try to change to a directory on a different drive without the /d switch, CMD will show an error like CMD does not support UNC paths as current directories or simply not change the drive. The /d switch is essential for cross-drive navigation.
How to Change Drives in CMD
Changing to a different drive (e.g., from C: to D:) requires a separate step. Simply typing cd D:\ will not work unless you use the /d flag. The correct ways are:
- Type
D:and press Enter — this switches to the D: drive, but you’ll land in the last directory you were in on that drive. - Type
cd /d D:\Projects— this switches to D: and directly enters theProjectsfolder. - If you’re already on D:, just use
cd Projectsto move within that drive.
For network paths (UNC paths like \\server\share), CMD does not support them directly as a current directory. You must map the network location to a drive letter (e.g., net use Z: \\server\share) and then use cd /d Z:\folder.
Common Mistakes and How to Avoid Them
Several errors trip up beginners and even experienced users:
- Forgetting the /d switch for cross-drive moves: Always use
cd /dwhen the target is on a different drive. - Omitting quotes for paths with spaces:
cd C:\My Documentsfails because CMD sees two arguments. Usecd "C:\My Documents". - Using backslashes instead of forward slashes: Windows uses backslashes (
\) in paths, not forward slashes (/). Forward slashes are for Unix/Linux. - Typing the drive letter without a colon:
Dalone does nothing; you needD:. - Case sensitivity: CMD is not case-sensitive, so
cd documentsworks even if the folder is namedDocuments.
If you get an error like “The system cannot find the path specified,” double-check the spelling and confirm the folder exists using dir to list the current directory’s contents.
Using Relative vs. Absolute Paths
A relative path is based on your current location. For example, if you’re in C:\Users\YourName, typing cd Desktop moves to C:\Users\YourName\Desktop. An absolute path always starts from the drive root, like cd C:\Windows\System32.
Relative paths are handy for quick moves within a project folder. You can combine them with .. to go up multiple levels. For instance, from C:\Projects\Website\CSS, typing cd ..\.. takes you to C:\Projects. The . (dot) refers to the current directory, but it’s rarely used with cd.
To see your current directory at any time, type cd without any arguments — it prints the full path. This is useful when you’re lost in a deep folder structure.
Advanced Tips and Shortcuts
Beyond the basics, these tricks can speed up your navigation:
- Tab completion: Start typing a folder name and press Tab to auto-complete it. Press Tab repeatedly to cycle through matches.
- Drag and drop: Type
cdwith a space, then drag a folder from File Explorer into the CMD window — the full path is inserted automatically. - Use the /? switch:
cd /?shows the built-in help for the command, including all switches. - Go to the previous directory: There’s no direct command, but you can use
cd ..to go up, or usepushdandpopdto save and restore directories. - For PowerShell users: The
cdalias works, but you can also useSet-Locationor the shortersl.
If you frequently need to jump to a specific folder, consider creating a batch file with cd /d C:\Your\Path and placing it in your PATH.
Frequently Asked Questions
Why does cd not work when I type a drive letter like D:?
Typing D: alone changes the drive, but CMD does not automatically change to the root directory — it goes to the last directory you were in on that drive. To go directly to a specific folder, use cd /d D:\Folder.
How do I go back to the previous directory in CMD?
There is no built-in cd - like in Linux. You can use cd .. to go up one level, or use pushd to save the current directory and popd to return to it later.
Can I change to a folder with a space in its name?
Yes, you must enclose the entire path in double quotes. For example: cd "C:\Program Files". Without quotes, CMD interprets the space as a separator and fails.
What does “CMD does not support UNC paths” mean?
UNC paths are network paths like \\server\share. CMD cannot set a UNC path as the current directory. You need to map the network location to a drive letter using net use Z: \\server\share, then use cd /d Z:\.
Is cd the same in PowerShell?
Yes, cd is an alias for Set-Location in PowerShell, so the basic usage is the same. However, PowerShell also supports forward slashes and has additional features like cd ~ to go to your home directory.
How do I change directory to a folder on a different drive without using /d?
You can switch drives first by typing the drive letter (e.g., D:), then use cd with a relative or absolute path on that drive. This is a two-step process, whereas cd /d does it in one.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Change Google Text-to-Speech Voice on Android
- How to Adjust Volume Levels on a Windows PC
- Reset Chrome Sync to Fix Problems
- Fix Mouse Not Working in Windows 11
- Fix Windows Defender Failed to Initialize Error
- App Installation History Mac OS X: How to View It