Sub topic 2
Navigating and managing folders: dir, cd, md, rd
This chapter assumes you can open an elevated Command Prompt and read a command's help with /?. It also assumes you know what a drive letter and a path are. Four commands cover most folder work on the A+ exam: dir, cd, md, and rd.
The working model
Command Prompt always has a current directory. A relative path such as Projects is resolved from it. An absolute path such as C:\Users\Sam\Projects starts at a drive root and works from anywhere.
| Command | Purpose | Common switches |
|---|---|---|
| `dir` | List files and folders | `/a` shows hidden and system items, `/s` recurses into subfolders, `/o` sorts, `/b` prints bare names |
| `cd` (or `chdir`) | Show or change the current folder | `/d` also switches drive |
| `md` (or `mkdir`) | Create a folder | Creates missing parent folders automatically |
| `rd` (or `rmdir`) | Remove a folder | `/s` removes contents too, `/q` suppresses the confirmation |
Walkthrough
The following session creates a folder tree, moves around in it, and removes it.
cd /d C:\
md Lab\Logs\2026
cd Lab\Logs
dir
cd ..
cd \
dir C:\Lab /s /b
rd /s /q C:\Labcd /d C:\switches to drive C and its root. Without/d, a plaincd D:\Datachanges the remembered folder on drive D but leaves you on your current drive.md Lab\Logs\2026creates all three levels in one command.cd Lab\Logsmoves down two levels.cd ..moves up one level, andcd \jumps to the drive root.dir C:\Lab /s /blists every item underC:\Labas a bare full path, which suits scripts and quick checks.rd /s /q C:\Labdeletes the folder and everything inside it, with no prompt.
Common errors
- Paths with spaces. Wrap them in quotes, as in
md "C:\Program Files Test". Without quotes,mdcreates two folders. - "The directory is not empty."
rdalone only removes empty folders. Add/sto remove the contents. - "Access is denied." The folder may be protected or in use, or the prompt may not be elevated. Open Command Prompt as administrator and retry.
- Missing items in
dir. Hidden and system files do not appear unless you add/a. - Wrong drive. The prompt shows the current drive. Check it before you run a recursive delete.
Exercise
You are in D:\Reports and need to switch to C:\Windows\System32 in one command. Which command do you use, and why does plain cd C:\Windows\System32 fail to do this?
Show answer
Use cd /d C:\Windows\System32. Without /d, cd changes only the saved folder for drive C and does not switch the current drive, so the prompt stays on D.
Exercise
A folder C:\Temp\Old contains files. rd C:\Temp\Old reports that the directory is not empty. Which command removes the folder and its contents without prompting?
Show answer
rd /s /q C:\Temp\Old