How to Create and Manage Folders in Windows CMD (Complete Guide)

In this tutorial, you will learn how to create folders in Windows CMD using the mkdir command. This method is the fastest way to manage directories and works perfectly in both the Windows Command Prompt and Windows PowerShell.

How to Navigate Directories in CMD

Before creating a folder, you must navigate to the correct location. To switch folders in Windows CMD, we use the cd (Change Directory) command.

cd /folder/path

For example, to move from your home directory to the Documents folder, type:

cd Documents

How to Create a Folder using mkdir

To create a new directory, use the mkdir command followed by your desired folder name:

mkdir folder1

After running this, you can use the dir command to list the contents of your current path and verify that "folder1" was created successfully.

Creating Folders with Spaces

If your folder name contains a space, you must put the folder name inside quotes. If you don't use quotes, CMD will interpret the space as a separator and create two different folders.

  • Avoid: mkdir new folder (This creates a folder named "new" and another named "folder").
  • Correct: mkdir "new folder" (This creates a single folder called "new folder").

Creating and Deleting Files in Command Prompt

While Windows CMD doesn't have a built-in command-line editor like Vim or Nano, you can still create files easily using the notepad command.

Create a Text File with Notepad

To create a new file, use the notepad command. This opens the Notepad GUI editor:

  1. Type notepad file1.txt.
  2. When the prompt asks, "Do you want to create a new file?", click Yes.

How to Delete a File

To delete a regular file, the command is del:

del file1.txt

How to Delete Folders (Directories)

To delete a folder, use the rmdir (Remove Directory) command.

Deleting Non-Empty Folders

If a folder contains files or other subfolders, a simple rmdir will not work. You must use specific flags:

  • /s Option: Deletes the folder and all subfolders/files within it.
  • /q (Quiet) Option: Deletes the folder without asking for confirmation.

The final command to force delete a folder is:

rmdir /s /q "folder name"

Quick Reference CMD Command Table

TaskWindows CMD Command
Create New Foldermkdir folder_name
Change Directorycd folder/path
List Folder Contentsdir
Create Text Filenotepad file_name.txt
Delete a Filedel file_name
Delete Folder (Empty)rmdir folder_name
Delete Folder (With Files)rmdir /s /q folder_name

So that's how we create and delete folders in Windows CMD.