DEV Community

Cover image for Windows CD Command Explained: Move Through Folders Fast
arnostorg
arnostorg

Posted on

Windows CD Command Explained: Move Through Folders Fast

The Windows CD command (Change Directory) moves your Command Prompt session into another folder. Almost every CLI workflow starts here: you cd to the right place, then run dir, scripts, builds, or tools.

Official reference: Microsoft Learn — CD / CHDIR.

What does CD do?

cd Documents
Enter fullscreen mode Exit fullscreen mode

If you were in C:\Users\You, you are now in C:\Users\You\Documents. The prompt path updates so you always know where you are.

chdir is the same command — cd is the short form everyone uses.

Essential CD patterns

Go up one level

cd ..
Enter fullscreen mode Exit fullscreen mode

From C:\Users\You\Documents you land in C:\Users\You.

Go up two levels:

cd ..\..
Enter fullscreen mode Exit fullscreen mode

Jump to a drive’s root

cd \
Enter fullscreen mode Exit fullscreen mode

That goes to the root of the current drive (for example C:\).

Switch drives

cd alone does not change the active drive letter the way beginners expect. To work on D::

D:
cd \Projects
Enter fullscreen mode Exit fullscreen mode

Or in one step with /d:

cd /d D:\Projects
Enter fullscreen mode Exit fullscreen mode

/d means: change drive and directory together. Memorize this — it saves constant confusion.

Paths with spaces

Quote them:

cd "C:\Program Files"
Enter fullscreen mode Exit fullscreen mode

Without quotes, CMD splits on the space and fails.

Absolute vs relative

  • Relative: cd Documents (from where you are)
  • Absolute: cd C:\Users\You\Documents (full path)

Use absolute paths in scripts; relative paths when exploring by hand.

Handy navigation tricks

See where you are

cd
Enter fullscreen mode Exit fullscreen mode

With no arguments, cd prints the current directory.

Tab completion

Type cd Doc then press Tab — CMD expands matching folder names. Fewer typos, faster moves.

Jump back with pushd / popd

pushd C:\Windows\System32
rem ... do work ...
popd
Enter fullscreen mode Exit fullscreen mode

pushd saves your place and moves; popd returns. Great for quick detours.

Quick reference

Goal Command
Enter folder cd FolderName
Up one level cd ..
Drive root cd \
Drive + folder cd /d D:\Work
Path with spaces cd "Program Files"
Print location cd

Practice CD until it is automatic

Folder navigation is the foundation of every other command.

CMD Master is a free online interactive learning platform for the command line. Practice Windows CMD, PowerShell, and Bash in a live browser terminal with instant feedback — no install, no VM. Most lessons are free. For a guided Windows path, open the interactive Windows Command Prompt course.

Further reading

Top comments (0)