How to cd in cmd

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: Use the cd command in Windows Command Prompt (cmd) exactly as you would in other shells: 'cd FolderName' to change directories. For folders with spaces, use quotes: 'cd "Program Files"'. You can also use backslash paths and absolute paths like 'cd C:\Users\Documents'.

Key Facts

What It Is

The cd command in Windows Command Prompt (cmd.exe) is the Windows equivalent of the Unix cd command, used to change the current working directory in the shell. Command Prompt is the legacy command-line interface for Windows that predates PowerShell, still widely used by system administrators, developers, and batch script writers. The cd command's basic function is identical across all operating systems—navigate between folders—but Windows has unique quirks like drive letters and backslash separators. Understanding cd in Command Prompt is essential for Windows system administration, batch scripting, and legacy application deployment.

The Command Prompt application originated in MS-DOS in the 1980s, and the cd command has remained largely unchanged since DOS 2.0 was released in 1983. The chdir command is the full name for cd, which is just an alias that Windows maintains for backward compatibility spanning four decades. When Windows NT introduced modern directory structures with backslash separators in 1993, the cd command was adapted to use backslashes instead of forward slashes. The command has persisted through Windows 95, XP, Vista, 7, 8, 10, and 11, making it one of the most stable commands in computing.

There are two variations of the command: simple 'cd' navigation within the current drive, and absolute path navigation starting from a drive letter. When you need to navigate to a different drive (C:, D:, E:), you must first run the drive letter command (like 'D:') before using cd. Relative paths work with cd: 'cd ..' goes to the parent folder, 'cd .' stays in current folder, and 'cd ..\..\Documents' navigates up two levels then into Documents. Understanding when to use absolute versus relative paths is crucial for writing portable batch scripts.

How It Works

Command Prompt tokenizes your input by spaces, then interprets the first token as a command and remaining tokens as arguments. The cd command parses its argument as a file system path and checks if a directory with that name exists relative to your current location. If the directory exists, Command Prompt updates the internal 'current working directory' state, which affects all subsequent commands and is displayed in the prompt (typically 'C:\Users\YourName>'). If the directory doesn't exist, Command Prompt returns 'The system cannot find the path specified.' error message.

For a practical example, consider a Windows developer using Command Prompt to navigate their project folders: starting in 'C:\Users\John\', they run 'cd Documents\Projects\MyApp' to navigate into that nested folder. The prompt then shows 'C:\Users\John\Documents\Projects\MyApp>' reflecting the new location. If they want to navigate to a different drive, 'cd D:\Backups' alone doesn't work—they must first type 'D:' to switch to that drive, then use 'cd Backups'. A system administrator managing backups uses absolute paths: 'cd C:\Program Files\BackupSoftware\logs'.

Step-by-step navigation process: (1) open Command Prompt by searching for 'cmd' in Windows Start menu, (2) type your cd command with the target path, (3) press Enter, (4) observe the prompt changes to show your new location, (5) type 'dir' to list files in the new location if desired. For changing drives, type the drive letter with a colon first: 'E:' takes you to the E: drive, then 'cd MyFolder' navigates within that drive. Using absolute paths is generally safer in batch scripts: 'cd C:\Users\Public\Documents' works regardless of your starting location, while 'cd Documents' only works if Documents exists in the current directory.

Why It Matters

Command Prompt usage remains critical in Windows system administration—approximately 3 million IT professionals globally regularly use Command Prompt for system management tasks. According to Gartner, 89% of enterprises still maintain Windows-based systems requiring Command Prompt knowledge. Batch scripting, which relies entirely on Command Prompt commands, powers millions of automated tasks in corporations worldwide, from overnight database backups to scheduled system updates. The inability to use cd prevents all downstream command operations, making this a fundamental blocker for anyone managing Windows systems.

In software development, developers working with Windows often encounter batch build scripts (.bat files) that use cd to navigate project directories before compiling code. Legacy systems in hospitals, manufacturing, and finance frequently run batch jobs written in the 1990s-2000s that depend on proper cd usage. Microsoft's own deployment automation, Azure DevOps agents, and many enterprise CI/CD pipelines execute batch scripts that rely on cd for directory navigation. DevOps engineers managing Windows Server infrastructure use Command Prompt and cd commands when remote PowerShell access is unavailable.

Future trends show Command Prompt usage declining as organizations migrate to PowerShell and Windows Terminal, which offer more modern syntax and features. However, legacy support requirements mean Command Prompt will remain relevant for decades—organizations with 20+ year old systems still rely on original batch scripts. The rise of containerization with Windows Containers and Docker still requires Windows system administration knowledge. As more infrastructure moves to Windows Server environments, especially in government and finance sectors, Command Prompt competency remains a valuable skill.

Common Misconceptions

Misconception 1: 'Forward slashes (/) work in Windows Command Prompt the same as backslashes.' This is false—while some modern Windows applications accept forward slashes, Command Prompt strictly requires backslashes for path separators. Typing 'cd Documents/MyFolder' fails in Command Prompt, but 'cd Documents\MyFolder' works. The confusion arises because PowerShell and modern CLI tools accept forward slashes, but traditional Command Prompt does not. This misconception leads users to fail navigation attempts when switching between command-line tools.

Misconception 2: 'The cd command can change drives, so cd D:\Folder works from any location.' This is partially false—while the full path works, best practice is to first type the drive letter ('D:') then use cd. Actually, 'cd D:\Folder' does work and changes both the drive and directory in one command in modern Windows, but many legacy batch scripts and older documentation recommend the two-step approach. The misconception stems from outdated advice that hasn't been updated to reflect modern Command Prompt behavior, though the two-step approach remains safer for complex scripts.

Misconception 3: 'If a folder name is long or has spaces, I should use a different method instead of cd.' This is unnecessary—cd handles long names and spaces perfectly when you quote the path: 'cd "Program Files"' or 'cd "C:\Users\Very Long Folder Name\Documents"'. The solution is proper quoting, not avoiding cd or using alternative approaches. Some users resort to using drag-and-drop in File Explorer to fill paths, but this is less efficient than typing quoted paths. The misconception prevents users from developing proper command-line skills.

Related Questions

Related Questions

How do I change to a different drive in Command Prompt?

Type the drive letter followed by a colon, like 'D:' to switch to the D: drive. After switching drives, use cd to navigate within that drive. Alternatively, use an absolute path: 'cd D:\Folder' changes to that folder on D: in a single command, which is now the preferred modern approach.

What's the difference between cd and chdir in Command Prompt?

They are completely identical—chdir is the full command name and cd is an alias. Windows accepts both interchangeably. The cd alias exists for backward compatibility with MS-DOS. Users typically prefer cd because it's shorter, but batch scripts may use chdir for clarity.

Can I use cd with relative paths like ../ or ./?

Yes, Command Prompt supports relative paths: 'cd ..' goes to the parent directory, 'cd .' refers to current directory, and 'cd ..\..\folder' navigates up two levels then into a folder. However, forward slashes don't work—use backslashes: 'cd ..\Documents' not 'cd ../Documents'.

Sources

  1. Cmd.exe - WikipediaCC-BY-SA-4.0
  2. MS-DOS - WikipediaCC-BY-SA-4.0

Missing an answer?

Suggest a question and we'll generate an answer for it.