From the command line, Windows allows us to create directories using the mkdir
(or MD) command. Here is an explanation of how to use this command.
How to Create Directory in Mkdir Command Prompt?
The command line is used to create a folder:
mkdir foldername
Using the following command, you can create a folder named “newfolder”:
mkdir newfolder
The hierarchical structure of the directory:
With the mkdir
command, we can create hierarchies of multiple directories (creating folders and subfolders all at once).
In the example below, folder 1 would be created as well as a subfolder called folder 2.
mkdir folder1\folder2\folder3.
You can run the sequence of commands below with the above command.
mkdir folder1 mkdir folder1\folder2 mkdir folder1\folder2\folder3
Problems with permissions:
For this command to be effective, you will need permission to create a folder. A folder cannot be created if its permissions are not granted.
C:\Users>mkdir c:\Windows\System32\test Access is denied.
A command that attempts to run against a similar file or folder will result in an error.
C:\>md test A subdirectory or file test already exists.
Make sure you haven’t hidden any files and folders with that name if you don’t see them.
A guide to handling whitespace:
Please enclose the name within double quotes if there is to be a space within it. You would type the commands below to create a folder named “My data”
c:\>mkdir "my data"
How to Create multiple folders?
Create multiple folders with the mkdir
command. The following are the instructions you can follow to create all the folders that you want to create.
C:\>mkdir folder1 folder2 subfolder1/folder3 subfolder2/subfolder21/folder4
That command is incorrect in its syntax:
Using Linux-formatted pathnames causes this error. Use Windows pathnames instead. When browsing directories on Linux, the paths are separated by a ‘/’, but on Windows, they are separated by a ‘\’.
c:\>mkdir folder1/folder2 The syntax of the command is incorrect.
As a rule of thumb, you should:
c:\>mkdir folder1\folder2
FAQs –
Question: What is mkdir in CMD?
Answer: The process of creating a new directory or subdirectory. By default, command extensions allow you to create intermediate directories by using the mkdir
command in a specified path. There is no difference between this command and md. You understand how to use mkdir command prompt.
You may also like: How to Rename File in CMD [Command Prompt]