how to create a directory in command prompt

Commandline Walkthrough: Create a Directory in Windows XP/Vista/7/8/10

By Kevin Martin
AD

Creating a directory is a fundamental task in the world of command-line interfaces, enabling you to organize your files and folders efficiently. The command prompt, an interface for interacting with the operating system, allows you to create directories swiftly. Let's delve into the process, breaking down the steps into easy-to-understand sections.

Whether you're a seasoned user or just beginning your journey with command prompt, understanding how to create a directory is a crucial skill. Let's get started!

Understanding Directories and the Command Prompt

In computing, a directory is a file folder or a collection of files and other directories. It's like a storage unit for your digital assets. The command prompt, or command-line interface, is a text-based interface for interacting with your computer's operating system.

AD
How to Navigate Directories and Folders in the Windows Command Prompt
How to Navigate Directories and Folders in the Windows Command Prompt
How to Make a New Directory and Change to It with a Single Command in Linux
How to Make a New Directory and Change to It with a Single Command in Linux
5 Fun Command Prompt Tricks
5 Fun Command Prompt Tricks

Before you begin, ensure you have access to the command prompt. On Windows, press the Windows key + R to open the Run dialog box, type 'cmd', and hit Enter. On macOS or Linux, press Ctrl + Alt + T to open the terminal.

Basic Directory Operations in Command Prompt

Creating a directory is just one of the fundamental operations you can perform using the command prompt. Understanding a few key commands will help you navigate the world of directories with ease. Here are some basic operations:

Basic Command Prompt Tricks Every User Should Know (Windows CMD Guide)
Basic Command Prompt Tricks Every User Should Know (Windows CMD Guide)
Terminal Prompt Symbols Explained for Cybersecurity Beginners
Terminal Prompt Symbols Explained for Cybersecurity Beginners
How to Open Files and Folders in CMD on Windows
How to Open Files and Folders in CMD on Windows
  • pwd - Prints the full path of the current directory (used in Unix-based systems like Linux and macOS).
  • cd - Changes the current directory.
  • ls - Lists all files and directories in the current directory (used in Unix-based systems).
  • dir - Displays a list of files and subdirectories in the specified directory or in the current directory if no directory is specified (used in Windows).

Creating a Directory: The 'mkdir' Command

The 'mkdir' command is used to create a new directory in the command prompt. Here's the basic syntax:

mkdir [directory_name]

AD

For example, to create a directory named 'Projects', you would type in the command prompt:

Command Prompt Commands: How to Use and Navigate CMD
Command Prompt Commands: How to Use and Navigate CMD
15+ Best CMD Tricks And Hacks (Command Prompt) 2025 - [Top List] - Safe Tricks
15+ Best CMD Tricks And Hacks (Command Prompt) 2025 - [Top List] - Safe Tricks
How to Open Command Prompt: A Comprehensive Guide
How to Open Command Prompt: A Comprehensive Guide
the basic commands for using command commands
the basic commands for using command commands
A Beginner's Guide to the Windows Command Prompt
A Beginner's Guide to the Windows Command Prompt
the essential guide to windows cmd commands you should know
the essential guide to windows cmd commands you should know

mkdir Projects

Press Enter, and the directory will be created in the current directory.

AD

Creating Nested Directories

Often, you'll need to create directories within directories. This is known as creating nested directories. The 'mkdir' command can handle this with ease using the '-p' option.

an image of a black screen with text
an image of a black screen with text
How to Customize the Command Prompt in Windows
How to Customize the Command Prompt in Windows

Creating a Single Directory with '-p' Option

The '-p' option with 'mkdir' allows you to create parent directories as needed. Here's an example:

mkdir -p directory1/directory2/directory3

AD

In this example, 'directory1' will be created if it doesn't exist. Then, 'directory2' will be created inside 'directory1', and finally, 'directory3' will be created inside 'directory2'.

Creating Multiple Directories Simultaneously

You can also create multiple directories at once using 'mkdir'. Here's how:

mkdir dir1 dir2 dir3

This command will create three directories named 'dir1', 'dir2', and 'dir3' in the current directory.

Remember, the command prompt is case-sensitive, so 'mkdir' and 'Mkdir' are not the same command. Consistency in your commands will help prevent potential errors.

Verifying Directory Creation

After creating a directory, it's always a good practice to verify that it has been created successfully. You can use the 'ls' or 'dir' command to list all the files and directories in the current directory.

Using 'ls' Command

In Unix-based systems, the 'ls' command lists all the files and directories. Here's an example:

ls

If you want to see detailed information about the files and directories, use:

ls -l

Using 'dir' Command

In Windows, the 'dir' command displays a list of files and subdirectories in the specified directory:

dir

Now that you've learned how to create a directory in the command prompt, you can enhance your productivity by organizing your files and folders effectively.

As you gain more experience with the command prompt, you'll find that it becomes a powerful and efficient tool for managing your files and directories. The next step might be learning how to delete a directory or copy files between directories.

AD