Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

mkdir Command Windows: How to Create Folders via CLI

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To create a new directory (folder) using the Windows command line, type mkdir folder_name (or the shorthand md folder_name) and press Enter. This command allows you to generate folders instantly without using the graphical File Explorer interface, which is essential for automation, scripting, and managing remote servers.

What You'll Need

  • A computer running a Windows operating system (Windows 10, Windows 11, or older versions).
  • Access to a command-line interface, such as Command Prompt (CMD) or Windows PowerShell.
  • Necessary administrative permissions if you intend to create folders in protected system directories like C:\Windows or C:\Program Files.

Step-by-Step

  1. Open the Command Line Interface: Click the Start button, type cmd or powershell into the search bar, and press Enter. You can also press Windows Key + R, type cmd, and hit Enter.
  2. Navigate to the Target Location: By default, the command prompt usually opens in your user profile folder (e.g., C:\Users\YourName). To create a folder elsewhere, use the cd (change directory) command. For example, to move to the Documents folder, type cd Documents and press Enter. If the folder is on a different drive, type the drive letter followed by a colon (e.g., D:) and press Enter first.
  3. Execute the mkdir Command: Type mkdir followed by a space and the name you want for your new folder. For example: mkdir ProjectFiles. Press Enter.
  4. Verify the Creation: To ensure the folder was created successfully, type dir and press Enter. This lists all files and folders in the current directory. Look for your new folder name in the list.
  5. Create Multiple Folders Simultaneously: If you need several folders at once, you can list them separated by spaces. For example, typing mkdir Images Videos Documents Backups will create four separate folders in one action.
  6. Create Nested Directories (Parent-Child Folders): Windows allows you to create a chain of folders in one go. If you type mkdir Work\2026\Invoices, Windows will create the "Work" folder, then a "2026" folder inside it, and finally an "Invoices" folder inside that.

Common Mistakes

One of the most frequent errors is forgetting to handle spaces in folder names. If you type mkdir My New Folder, Windows interprets this as a request to create three separate folders: one named "My", one named "New", and one named "Folder". To create a single folder with spaces in the name, you must enclose the name in double quotation marks, such as mkdir "My New Folder".

Another common mistake is attempting to create a folder in a directory where the user does not have write permissions. For instance, trying to run mkdir TestFolder while the prompt is at C:\Windows\System32 will typically result in an "Access is denied" error. This happens because system directories are protected to prevent accidental modification of the operating system.

Users also sometimes confuse the mkdir command with the cd command. Remember that mkdir creates the folder, while cd enters the folder. Running mkdir MyFolder does not automatically move you into that folder; you must run cd MyFolder afterward to begin working inside it.

Tips

For those who prefer brevity, md is a fully functional alias for mkdir. Typing md FolderName performs exactly the same action and is faster to type during repetitive tasks.

When organizing large projects, use the nested directory tip mentioned in the steps. Instead of running three separate commands to build a hierarchy, the path-based approach (mkdir Folder1\Folder2\Folder3) saves significant time and reduces the chance of typos.

If you are creating folders as part of a batch script (.bat file), you can use the mkdir command to set up an entire project environment automatically. This is highly useful for developers who need a consistent folder structure (e.g., /src, /bin, /docs) every time they start a new project.

Combine the mkdir command with the cd command using the & operator to create and enter a folder in one line. For example: mkdir NewProject & cd NewProject. This tells Windows to execute the first command and then immediately execute the second.

Troubleshooting

Error: "Access is denied"
This occurs when you lack the necessary permissions to write to the current directory. To fix this, you must run the command prompt as an administrator. Right-click the Command Prompt icon in the Start menu and select "Run as administrator". Once the elevated prompt opens, navigate back to your target directory and try the command again.

Error: "A subdirectory or file ... already exists"
This means there is already a folder or a file with the exact name you are trying to use. You cannot have two items with the same name in the same directory. To resolve this, choose a different name for your folder or delete the existing item if it is no longer needed.

The folder was created, but I can't find it
You may have created the folder in a different directory than you intended. Type cd (with no arguments) and press Enter to see your current working directory. If you are in the wrong place, use cd .. to move up one level or cd \ to go to the root of the drive, then navigate to the correct location.

The command is not recognized
While mkdir is a built-in internal command for CMD and PowerShell, if you receive a "not recognized as an internal or external command" error, it usually suggests a corrupted system path or a highly restricted environment. Try switching from Command Prompt to PowerShell (or vice versa) to see if the issue persists.

Frequently Asked Questions

Can I create a folder with a name that starts with a number?

Yes, Windows allows folder names to start with numbers. For example, mkdir 2026_Reports is a perfectly valid command.

Is there a limit to how deep I can nest folders using mkdir?

While mkdir can create nested paths, Windows has a maximum path length limit (traditionally 260 characters). If your combined folder names and paths exceed this limit, the command will fail.

How do I delete a folder created with mkdir?

To remove an empty folder, use the rmdir (or rd) command. For example: rmdir ProjectFiles. If the folder contains files, you will need to use rmdir /s ProjectFiles to remove the folder and all its contents.

Does mkdir work the same in PowerShell and CMD?

Yes, in both environments, mkdir functions as expected. In PowerShell, mkdir is actually a function that wraps the New-Item cmdlet, but the syntax for creating a directory remains the same for the user.

Can I create a folder on a network drive using mkdir?

Yes, provided you have the appropriate network permissions. You can use the UNC path, such as mkdir \\ServerName\SharedFolder\NewFolder, or map the network drive to a letter (like Z:) and navigate to it first.