ShareYourGroupShareYourGroupCommands

Windows commands

cd, mkdir and rmdir: move between folders and make them

The Command Prompt is always "in" one folder, shown before the > sign. Commands act on that folder unless told otherwise. cd moves you to a different one. mkdir makes a new folder and rmdir removes one.

Where am I?

cd on its own prints the current folder.

Windows Command Prompt
C:\Users\asha\demo>cd
C:\Users\asha\demo

Going into a folder, and back out

Windows Command Prompt
C:\Users\asha\demo>cd photos
C:\Users\asha\demo\photos>dir /b
beach.jpg
hills.jpg
C:\Users\asha\demo\photos>cd ..

Two dots mean "the folder above this one". The prompt changes each time to show where you are.

Paths

A path is the route to a folder. There are two kinds.

Windows separates the parts of a path with a backslash.

You typeYou go to
cd photosthe photos folder inside the current one
cd ..the folder above
cd ..\..two levels up
cd \the top of the current drive
cd ..\oldup one level, then into old
cd C:\Usersthat exact folder

Pressing Tab after typing the first letters of a name completes it. Pressing Tab again shows the next match. It saves typing and prevents spelling mistakes.

Changing drive

cd does not switch drives by itself. Type the drive letter and a colon to change drive, or add /d to do both at once.

Windows Command Prompt not run here
D:
cd /d D:\Backups

Names with spaces

Put the path in double quotation marks.

Windows Command Prompt not run here
cd "C:\Program Files"

Making folders with mkdir

Windows Command Prompt
C:\Users\asha\demo>mkdir reports
C:\Users\asha\demo>mkdir reports\2026\november
C:\Users\asha\demo>dir /ad /b
old
photos
reports
C:\Users\asha\demo>dir /s /b reports
C:\Users\asha\demo\reports\2026
C:\Users\asha\demo\reports\2026\november

mkdir creates any missing folders along the way, so the second command made both 2026 and november. The short form md does the same.

If the folder already exists, the command says so and does nothing.

Windows Command Prompt
C:\Users\asha\demo>mkdir photos
A subdirectory or file photos already exists.

Removing folders with rmdir

rmdir, or rd, removes an empty folder.

Windows Command Prompt
C:\Users\asha\demo>mkdir empty
C:\Users\asha\demo>rmdir empty
C:\Users\asha\demo>rmdir photos
The directory is not empty.

The last command was refused: photos has files in it. That refusal is a safety feature.

Danger. rmdir /s foldername removes a folder with everything inside it, including all its subfolders. It asks once, and /q switches even that question off. Nothing goes to the Recycle Bin. Check the name and the current folder twice before using /s, and never run it on a path you typed from memory.

Windows Command Prompt not run here
rmdir /s old

pushd and popd

When you need to visit another folder briefly and come back, pushd folder goes there and remembers where you were, and popd returns.

Windows Command Prompt not run here
pushd old
popd

Opening File Explorer here

start . opens the current folder in a File Explorer window. Going the other way, typing cmd in File Explorer's address bar and pressing Enter opens a Command Prompt in that folder.

Common mistakes

On Linux and the Mac, the matching commands are cd, pwd, mkdir and rmdir.

Examples shown with output were run on 12 November 2026 in a practice folder: Windows commands in cmd.exe on Windows 11, Linux commands with the GNU tools of Git Bash. The folder path and user name were replaced with made-up ones. Commands marked "not run here" are shown as you would type them.

This is an independent learning site. It is not connected with Microsoft, Apple or any Linux distribution. Windows, macOS and other names belong to their owners. Try commands first in a practice folder, never on files you cannot afford to lose.