How to Change Directory in CMD (cd Command)

Folders in Command Prompt change with the cd command: type cd, a space and the folder you want, then press Enter. Going up one level takes two dots (cd ..), and a folder on another drive needs the /d switch, as in cd /d D:\Photos. Microsoft’s reference for the cd command gives the same syntax, and the sections below show which form fits where you are trying to go.

Pick the cd form that matches the destination

Find your situation in the left column and type the command beside it (swap in your own folder names).

Where you want to go Type this What happens
A folder inside the current one cd Reports Moves one level down into Reports
A folder anywhere on the same drive cd C:\Users\Public\Documents Jumps straight to that full path
The folder above this one cd .. Moves to the parent folder
Two levels up cd ..\.. Moves to the parent of the parent
The top of the drive cd\ Returns to the root, such as C:\
A folder on a different drive cd /d D:\Photos Changes the drive and the folder together
A folder with spaces in its name cd "Project Files" Opens it; the quotes keep the name in one piece
Nowhere, just checking cd Prints the current drive and folder

chdir is the same command under a longer name, so every example here also works with chdir in place of cd.

Check where you are before you move

The text in front of the blinking cursor (the prompt) already shows your current folder, for example C:\Users\Public>. Two commands tell you more:

  • cd on its own prints the current drive and folder. Typing a drive letter after it, as in cd D:, shows the folder Command Prompt last used on that drive without moving you there.
  • dir lists the files and subfolders in the current folder. Add /a:d (dir /a:d) to list only folders, /w for a wide list, or /p to pause one screen at a time when a folder holds a lot. Microsoft’s dir reference lists the other switches.

Running dir /a:d first is the quickest way to copy a folder name exactly as it’s spelled, which avoids most “path not found” errors later.

Move into a folder and back out again

This is the everyday loop. If you would rather have Command Prompt start inside a folder you already have open in File Explorer, that is a different job, covered in opening a folder in Command Prompt.

  1. Open Command Prompt. It typically starts in your user folder, which looks like C:\Users\<name>.
  2. Type dir /a:d and press Enter to see which folders are here.
  3. Type cd, a space and one of those names, for example cd Documents, then press Enter. The prompt changes to show the new folder.
  4. Go deeper by repeating step 3, or type a longer relative path in one go, such as cd Documents\Budget.
  5. Back up one level with cd .., or return to the top of the drive with cd\.
Command Prompt showing cd commands to open a folder, go up a level, and switch drives with cd /d
(1) Opening a folder with cd, and (2) switching drives and folders with cd /d. (Illustration)

A path that starts with a drive letter and a backslash (C:\...) is absolute: it works from anywhere. A path without one (Documents\Budget) is relative: it only works if that folder sits under where you are now. When cd fails, this difference is the first thing to check.

Want somewhere to practice without touching real files? Make an empty test folder with the mkdir command, then move in and out of it with cd and cd ...

Switch to another drive

This is the one that surprises people. If you are on C: and type cd D:\Photos, nothing seems to happen. Command Prompt keeps a separate current folder for each drive, so that command quietly sets the folder for D: while you stay on C:.

The fix is the /d switch, which Microsoft describes as changing “the current drive as well as the current directory for a drive”:

  • cd /d D:\Photos moves you to D: and into Photos in one step.
  • cd /d E:\ moves you to the top of a USB drive mounted as E:.

You may also see people type just the drive letter and a colon (D:) on its own line to change drives. Microsoft’s cd page documents only /d, so that is the form to rely on in scripts and instructions you share.

Folder names with spaces

Microsoft’s cd reference says that with command extensions turned on (the normal state), spaces aren’t treated as separators, so cd Program Files can work without quotes. With extensions turned off, the quotation marks are required.

Because you can’t always tell how a given window was started, wrap any path that contains a space in straight double quotes:

  • cd "Project Files"
  • cd /d "D:\Family Photos\2026"

Quotes never hurt a path without spaces, so adding them out of habit is a safe choice.

Save your place with pushd and popd

When you need to pop over to another folder and come straight back, pushd and popd save typing. Microsoft’s pushd reference says it stores the current directory for use by popd and then changes to the folder you name.

  1. Type pushd D:\Exports. pushd saves where you were and changes to the folder you name.
  2. Do what you came to do.
  3. Type popd. You are back in the folder you started from.

Saved folders sit on a stack, so several pushd commands in a row can be unwound one popd at a time, newest first.

Network folders: With command extensions enabled, pushd also accepts a network path such as pushd \\fileserver\shared. Microsoft says it temporarily assigns the highest unused drive letter, starting at Z:, to that network location and moves you there. popd then removes the drive letter it created. That makes pushd the documented way to work inside a shared folder from Command Prompt.

Skip typing your user name with variables

Windows keeps common folder locations in environment variables. Put the name between percent signs and Command Prompt swaps in the real path, so the same command works on any account.

Type Goes to
cd /d "%USERPROFILE%" Your user profile folder
cd /d "%APPDATA%" The application data folder where many apps keep settings
cd /d "%TEMP%" Your temporary folder; Microsoft gives a typical path of %USERPROFILE%\AppData\Local\Temp
cd /d "%SystemRoot%" The Windows folder (the same as %WINDIR%)

The /d and the quotes are there for safety: the Windows folder isn’t always on the drive you’re on, and a user name can contain a space. These variables come from Microsoft’s list of recognized environment variables.

Once you’re in the Temp folder you may be tempted to clear it out. Deleting files from the command line deserves care, and clearing temporary files with Command Prompt explains the safe way to scope those commands.

The same moves in PowerShell

If you work in PowerShell, or a PowerShell tab in Windows Terminal, cd still works, but it’s a different command underneath. Microsoft’s Set-Location reference lists cd, chdir and sl as its aliases.

  • No /d switch: Set-Location has no /d option. Microsoft’s examples move to another drive just by naming it, so cd D:\Photos works directly.
  • Spaces: quote the path the same way, cd "D:\Family Photos".
  • Back and forward: in PowerShell 6.2 and later, cd - returns to the previous location and cd + goes forward again, from a history of the last 20 locations.
  • Variables: PowerShell writes them differently, as $env:USERPROFILE rather than %USERPROFILE% (see Microsoft’s environment variables reference).

If you need to start PowerShell first, opening PowerShell covers the usual routes.

When cd can’t find the path

An error saying the path can’t be found almost always comes down to one of these, roughly in order of how often they happen:

  • Relative path from the wrong place. cd Budget only works if Budget is directly under the current folder. Run cd to see where you are, or use the full path.
  • Spelling. Compare with dir /a:d. Case doesn’t matter: Microsoft notes that cd c:\temp lands in C:\Temp, with the name shown the way it is spelled on the disk.
  • Wrong drive. The command ran but you’re still on C:. Add /d.
  • Spaces without quotes, in a window where command extensions are off. Add the quotes.
  • Network path with cd. Use pushd for shared folders, as shown above.
  • Permission errors. Some protected folders refuse access to a standard account. If you really need to work there, an administrator Command Prompt may be required; if a folder belongs to another user, leave it alone.

If Windows won’t start and you’re at a recovery prompt instead, drive letters can differ from the ones you know, so read Command Prompt before Windows starts before you change folders there.

Once moving around feels natural, the next skill is copying files from Command Prompt, which uses the same paths, quotes and drive rules you’ve just practiced.

cd command questions

Can Command Prompt finish folder names for me?

Microsoft’s cmd reference says name completion isn’t enabled by default and describes turning it on for a session with cmd /f:on; then Ctrl+D completes folder names, and with cd, completion assumes folders. It also notes that completion handles names with spaces when you put quotes around the path. That page doesn’t describe the Tab key, so if Tab completes names on your PC, check the finished path before pressing Enter.

How do I return to the folder I was in before?

If you got there with pushd, type popd. If you used cd, Microsoft’s cd reference lists no option for going back to the previous folder, so either retype the path or use cd .. to climb up. PowerShell 6.2 and later has cd -.

Does cd change anything on my PC?

No. It only changes which folder the Command Prompt window is working in. Nothing is created, moved or deleted, and closing the window forgets the location. That makes cd safe to experiment with; the care belongs with the commands you run after you arrive.