How to change directory

Overview

cd (also written chdir) displays or changes the current directory used by commands.

An absolute path starts from a drive root. A relative path starts from the current folder; .. means its parent and . means the current folder.

  • Run cd with no path to print the current folder.
  • Tab completion can finish folder names and add quotes where needed.
  • pushd remembers your location and popd returns to it.

Commands to try

Type each command at the prompt, then press Enter. Replace sample names and paths with ones that exist on your computer.

Commands are generally not case-sensitive, but preserving the spelling shown here makes scripts easier to read.

cd
cd /d "%USERPROFILE%\Documents"
cd ..
cd \
pushd "%TEMP%"
popd

Useful options and details

Options change how a command behaves. Add spaces exactly as shown, and use the command's built-in help when an option is unfamiliar.

A path containing spaces must be enclosed in double quotes, such as "C:\My Files".

  • /d changes the drive and directory together.
  • cd \ goes to the current drive's root.
  • Typing D: switches to drive D's remembered directory; cd /d D:\path is clearer.

Tips and common mistakes

Check the current folder and read the command output before assuming an operation succeeded.

Practice with disposable files first. Commands that delete, overwrite, or stop a process may not offer an Undo button.

  • The prompt may appear unchanged if you try to change to another drive without /d.
  • A path is not a command; use cd before it.
  • Avoid working in C:\Windows or application folders while practicing.

Safe practice

Create a temporary practice folder under your user profile so the examples cannot affect Windows system files.

After each command, inspect the result with dir or another read-only command before continuing.

  • Move to your profile, then into a known subfolder.
  • Go to the parent and return with pushd/popd.
  • Use cd to verify every location.