Windows Command Line cd: How to Change Folders in CMD
Windows command line cd makes folder changes predictable in CMD: see when to use /D, quote spaced paths, and switch drives or UNC locations without confusion.

tl;dr the short answer
The Windows Command Prompt cd command, short for “change directory,” changes the folder where commands run, or displays your current folder when used alone. Use relative or full paths to move, quote paths with spaces, and add /D when you need to switch drives as well as folders; pushd and popd help you return to saved locations and work with network shares. Knowing these differences makes navigation more predictable, especially when switching between Windows and bash.
Think about giving directions to a friend. You can say “go to the kitchen” and hope they find it, or spell out the full route. The cd command in the Windows Command Prompt (CMD) works the same way: it tells your terminal exactly where to go.
In short, cd (short for “change directory”) moves you from one folder to another. This post covers its syntax, the /D switch, quoting paths with spaces, the pushd and popd folder stack, and Universal Naming Convention (UNC) paths.
We’ll map each habit to bash so Linux and Windows Subsystem for Linux (WSL) users can follow along.
What the Windows Command Line Cd Does
cd is how you change the folder your commands run in. Here’s how it works on Windows, piece by piece.
What cd does in CMD and PowerShell
The name is short for change directory. Give cd a path and it changes your current directory, so the next file name you type starts looking there. Give it nothing and it displays the current one. It works the same in Command Prompt (CMD) and PowerShell.
A student keeps coursework in a folder called essays. From the parent folder, cd essays puts them inside, and later commands run there.
How cd and chdir are written
CD and CHDIR are equivalent, so either one gives the same result. Square brackets mark optional parts, and the syntax has three:
- /D switch: also changes the current drive, as in
cd /d D:\projects. - [drive:]: an optional drive letter and colon, such as
D:. - [path]: an optional folder location, such as
projects\essays.
Leave out /D and cd won’t switch drives, even if the path names one. Forget it once and you’ll wonder why nothing moved.
Check your current folder with plain cd
With no parameters, plain cd displays the folder you’re in, a quick check before a command runs. Type a drive letter, like cd D:, and it shows that drive’s current directory without moving you.
Bash handles a bare cd differently: it moves you to your home directory, while CMD only displays the folder you’re in. Picture a Linux user at a Windows machine who types cd out of habit, expecting to land at home.
Instead, they get a harmless readout of where they are, and nothing moves. Same keystroke, different result.
Moving Around Folders in CMD
Every cd command in CMD (the Windows Command Prompt) starts from your current directory, the folder shown at the prompt. Moving is mostly about naming where you want to go.
Step into a folder by name
To enter a folder, type cd and its name. If you’re in C:\Users\maya and want the Projects folder inside it, type cd Projects. That’s a relative path: it starts from where you are, not from the top of the drive.
Nested folders work the same way: cd Projects\web\src takes you three levels deep in one step.
Picture a Linux user with a new Windows laptop who wants the reports folder inside Documents without touching the mouse. From their user folder, cd Documents\reports gets them there in one line.
The folder has to exist, so if CMD says ‘path not found’, check the spelling first. Then type dir to see what’s really there. Linux users check the same thing with the ls command.

Going up a level or to the root
cd .. moves you up one level to the parent folder, and you can chain it: cd ..\.. climbs two levels at once.
cd \ takes you to the root of the current drive. It doesn’t switch drives, though. From D:\backups\2024, it lands you at D:\, the top of the same drive. Switching drives takes /D, which we’ll get to shortly.
Using shortcut paths like %USERPROFILE%
%USERPROFILE% expands to your profile folder, so cd %USERPROFILE%\Desktop lands on your Desktop from any folder. Relative names like Projects depend on where you are. This one spells out the full route, so it works from anywhere.
You’ll still spot cd "C:\Documents and Settings" in older guides and scripts. That’s the legacy path from earlier Windows versions, so swap in %USERPROFILE% instead. Less guessing, fewer errors.
Switching to a Different Drive
Windows remembers a separate current directory for each drive, and that detail trips people up when they switch drives in cmd. Here’s how /D handles it and what happens when you leave it out.
Using /D to change drive and folder
Add /D (short for drive) to cd and it changes the drive and the directory in one command. Say you want to work in your docs folder on E:. Run cd /d E:\docs and you’re on E: inside docs, with every later command running there.
What happens when you skip /D
Leave out /D and cd acts differently. Here’s what you get:
- Sets only that drive’s directory.
cd E:\docsupdates the remembered folder for E: and nothing else. - The active drive stays put. You’re still on your original drive, so your next commands run there.
- Type the letter to switch. When you’re ready, type
E:to make it your active drive and land in docs.
Nothing visibly changes. That’s the trap. Consider a Linux user who moves a bash project to E: and types cd E:\projects out of habit. Nothing seems to happen, so they run dir and still see C: files.
Adding /D fixes it in one step, and the next command finally runs where they expected. Plain cd sets a folder, while cd /d also switches you there.
If you also use WSL, Windows drives show up under /mnt, so E: becomes /mnt/e inside your Linux shell.

Handling Spaces, Quotes and Extensions
Spaces are the tricky part of cd, and what happens depends on command extensions, the cmd.exe features that change how cd reads its argument.
Here’s how we’ll work through quoting, case, and delimiters (the separators that split one argument from the next).
Quoting folder names that have spaces
Picture a Linux user who just moved a game project onto Windows, with assets in a folder called My Game Assets on drive D:. Quotes are the safe habit: cd "D:\My Game Assets" lands them in the right folder every time.
- Quotes are recommended. Wrap the path in double quotes even when they’re optional, because the boundaries become obvious to you and to anyone reading your batch files.
- No quotes with extensions. With command extensions enabled,
cd D:\My Game Assetsworks without quotes, and the next subsection explains why. - Quotes required if disabled. Turn extensions off and
cdtreats the space as a separator, so the quotes become required. - Bash: quote or backslash-escape spaces. Linux users already know this habit:
cd "My Game Assets"andcd My\ Game\ Assetsboth work in bash, so pick whichever reads better.
How extensions handle case and spaces
Command extensions also change two things about cd itself. The first is case matching: cd rewrites the directory string to use the same case as the names on disk. Type cd \my game assets and the prompt shows \My Game Assets, the real spelling.
The second is that spaces aren’t delimiters. With extensions on, cd reads the whole path as one argument, spaces included. Spaces stop being the trap.
Related Commands and the Folder Stack
Once cd feels natural, these companion commands save real keystrokes.
Saving folders and returning with popd
Think of a Linux user hopping between a project and a logs folder all afternoon. pushd changes folders while remembering where you were, and popd takes you back, just as Bash does.
Each pushd adds your location to a folder stack, so you can save several places. Start in C:\work, pushd to logs, then pushd to C:\reports. The first popd lands you in logs, and the second returns you to C:\work.
Saves come back in reverse order, so you get the most recent first, not the oldest. Last saved, first back.
Working with network shares and UNC paths
A UNC path (Universal Naming Convention) points to a shared network folder, like \\server\share. The catch is that cd can’t make a UNC path your current directory.
That’s where pushd earns its keep. It maps a temporary drive letter to the share and switches you there, and popd removes that mapping when you’re finished.
Picture a Linux user checking a build script on a shared server from a Windows laptop. One pushd gets them in, and one popd cleans up. The mapping is temporary rather than permanent, so no stray drive letter lingers.
Other commands that pair with cd
Here’s what to reach for next:
- Listing contents:
dirshows what’s in the current folder, likelsin Bash. - Confirming location:
pwdtells you where you are, and it works in PowerShell too. - PowerShell: It’s a separate shell with its own commands, so don’t assume every habit carries over.
- Saving a folder in a batch script: Record the starting folder with
set "start=%cd%", then return withcd /d "%start%". The/dswitch also changes drives.

Unix-style Options and Handy Habits
Ten basic Linux commands cover most daily work:
lslists filescdchanges folderspwdprints where you arecpcopies filesmvmoves or renamesrmdeletesmkdirmakes folderscatshows file contentsgrepsearches textmanopens the manual
Unix cd options for history and symlinks
Bash, the shell most Linux users meet first, gives cd a few extras. cd - jumps back to the folder you just left, so a developer hopping between ~/src/app and /var/log never retypes a path.
cd -P matters when you use symbolic links, shortcuts that point at another folder. Without -P, bash keeps the link’s name in your path. With it, you land in the real directory, and pwd shows the true path.
Add alias cd='cd -P' to .bashrc to make it the default.
Practical tips for everyday use
Tab completion saves typing. Type a few letters and press Tab, or press it twice to list matches.
Case sensitivity is the trap. Linux paths are case-sensitive, so cd Data and cd data can reach different folders, while Windows and default macOS setups don’t care.
A student’s script that runs fine on a Windows laptop can fail on a Linux server. Matching the case fixes it.
Combine cd with scripting to keep work in the right folder. In cd "$backup_dir" && ./run-backup.sh, the && runs the backup only if the cd succeeds.
Deleting files with rm works from the same prompt:
rm notes.txtremoves a file, andrm -r old-projectremoves a folder with everything in it.- Use
rm -ito confirm each delete. - rm skips the Recycle Bin, so there’s no undo.
To list all disks, run lsblk. It shows every disk and its partitions in a tree view, so you can spot the right drive first.
Once the basics click, cd stops being a source of tiny frustrations. You know when /D is needed, how quotes keep long folder names intact, and how pushd gives you a way back.
The bash habits you already have carry over, too, whether you’re on a Linux box or inside WSL.
Your terminal should feel like a place you know, not a maze. Know where you’re standing, and every command gets easier to trust.
Questions
What are 10 basic commands in Linux?
Ten basic Linux commands are `ls` to list files, `cd` to change folders, `pwd` to show your current location, `cp` to copy files, and `mv` to move or rename them. The others are `rm` to delete, `mkdir` to make folders, `cat` to display file contents, `grep` to search text, and `man` to open a command’s manual.
How to enter d:\ in cmd?
In Command Prompt, type `D:` and press Enter to switch to the D drive. To go to the drive’s root directory, type `cd \` after switching; to change to a specific folder, use a command such as `cd /d D:\Projects`.
How to go to c:\ in command prompt?
Type `C:` and press Enter to switch to the C drive. To go to its root directory, type `cd \`; `cd /d C:\` does both in one command.
How to go from C drive to D in cmd?
Type `D:` and press Enter to switch from C: to D:. Alternatively, use `cd /d D:\` to switch drives and go to D:’s root directory in one step.
How to use cd properly?
Use `cd` followed by a folder name or path to change your current directory, such as `cd Projects` or `cd ..` to move up one level. Use quotes around paths with spaces, for example `cd "D:\My Projects"`. In Command Prompt, use `cd /d D:\Projects` when you need to change both the drive and folder.
How do I delete files in Linux?
Use `rm filename` to delete a file in Linux, such as `rm notes.txt`. Use `rm -r foldername` to delete a folder and its contents, or `rm -i filename` to confirm before deleting; `rm` does not send items to a Recycle Bin.
How do I list all disks on Linux?
Run `lsblk` to list disks and their partitions in a tree view. You may need elevated permissions to see some device details.
What does cd stand for in Windows?
In Windows, `cd` stands for “change directory.” It changes the folder in which commands run; in Command Prompt, typing `cd` by itself displays your current folder.


