Windows cmd make dir

In Windows, we can create directories from command line using the command mkdir(or md). Syntax of this command is explained below.

Create a folder from command line:

mkdir foldername

For example, to create a folder named ‘newfolder‘ the command is:

mkdir newfolder

Create directory hierarchy

We can create multiple directories hierarchy(creating folder and sub folders with a single command) using mkdir command.
For example, the below command would create a new folder called ‘folder1’ and a sub folder ‘folder2’ and a sub sub folder ‘folder3’.

mkdir folder1\folder2\folder3.

The above command is same as running the below sequence of commands.

mkdir folder1
mkdir folder1\folder2
mkdir folder1\folder2\folder3

Permissions issue

Yoou need to have permissions to create folder for the command to work. Not having permissions to create folder would throw up ‘access denied’ error.

C:\Users>mkdir c:\Windows\System32\test
Access is denied.

If there exists a file or folder with the same name, the command throws up error.

C:\>md test
A subdirectory or file test already exists.

If you don’t see a file or folder with that name, make sure to check if it’s not hidden.

Handling whitespaces

If the name needs to have space within, you should enclose it in double quotes.
For example, to create a folder with the name ‘My data’, the command would be

c:\>mkdir "my data"

Creating multiple folders

mkdir command can handle creating multiple folders in one go. So you can specify all the folders you wanted to create like below

C:\>mkdir folder1 folder2  subfolder1/folder3 subfolder2/subfolder21/folder4

The syntax of the command is incorrect.

If you get this error, make sure you are using the directory paths in Windows format and not in Linux format. On Linux, the directory paths are separated with ‘/’, but in Windows it’s ‘\’.

c:\>mkdir  folder1/folder2
The syntax of the command is incorrect.

The right command is

c:\>mkdir  folder1\folder2

Not many Windows users are familiar with CMD. The common misconception is that only programmers and computer geeks use CMD. Basically, CMD is a tool that you can use to communicate with your Windows computer. Though the user interface and other input methods are introduced, CMD is one tool that you cannot take for granted. Some commands, such as creating folders, are easier to execute using CMD. You may laugh and think that it is harder to create a folder using CMD instead of using your mouse and the “Right click > New folder” method. You may have a point, but what if you are asked to create 10 folders or more? CMD would greatly simplify the task. Creating a folder using CMD is easy. This article will show you how.

Create a Folder Using CMD in Windows

To use CMD to create a folder on your Windows computer, follow these steps:

1.Click on the Search button located on the lower-left part of your computer’s screen.

Search button for Windows

2.In the Search box, type in CMD.

Type Search on CMD

3.Open CMD from the results.

Open CMD fro best match

4.With CMD opened, go to the drive where you want to put the folder. To go to the drive, type in the name of the drive followed by the colon (:) symbol. In this case, we want to go to Drive D so we input D:.

on CMD type the drive name

5.CMD’s directory will change to the chosen drive. Type in the MKDIR command to create a directory or folder. In this case, we want to make a folder named TECHRECIPE, so we type in mkdir TECHRECIPE into CMD.

Type in the Folder name

6.You are done. You can go to the newly created folder using CMD by typing in the command CD followed by name of the folder. In this case, type in CD TECHRECIPE in CMD.

change folder name on CMD

7.You can also use your computer’s user interface to see that the folder has been created.

New created Folder can be seen on the drive

Create Multiple Folders Using CMD in Windows

To create multiple folders using CMD, follow these steps:

1.Open CMD on your Windows computer.

Open CMD fro best match

2.Go to the directory or folder where you want to create the multiple folders. In this case, we will go to the newly created folder.

change folder name on CMD

3.Type in the MD command, followed by the names of the folders that you want to create. In this case, we want to create four folders named TR1, TR2, TR3 and TR4. Therefore, we input md TR1 TR2 TR3 TR4.

create multiple folder commands in CMD

4.The subfolders will be created. You can go to the folder using your computer’s user interface, and you will see that all the subfolders have been created.

Newly created folders

5.You are done.

Learning CMD is easy. If you want to know more about using CMD or if you have questions concerning any of the steps above, let us know in the comments section.

Leomar Umpad

A supply chain operations manager by profession. A technology-lover and a writer by heart. I have the passion to teach and inform.

The `mkdir` command in CMD is used to create a new directory (folder) in the specified location.

mkdir C:\ExampleFolder

Understanding the `mkdir` Command

The `mkdir` command stands as a fundamental tool in the command-line interface, specifically for creating new directories within the Windows operating system. The syntax for the `mkdir` command is simple yet powerful, allowing users to create directories quickly.

Mastering Cmd Directory Navigation Made Simple

Mastering Cmd Directory Navigation Made Simple

Basic Usage of `mkdir`

Creating a Single Directory

To create a single directory, the command is straightforward. Here’s how it works:

mkdir NewFolder

This command tells the system to create a new directory named NewFolder in the current working directory. Once executed, users can confirm the creation by using the `dir` command, which lists all directories and files in the current location.

Creating Multiple Directories at Once

One of the strengths of `mkdir` is its ability to create multiple directories simultaneously. For example, if you want to create three new folders in one command, you can use:

mkdir Folder1 Folder2 Folder3

This command effectively creates Folder1, Folder2, and Folder3 at once, streamlining the organizational process.

Mastering Cmd Rmdir: Effortless Directory Removal Guide

Mastering Cmd Rmdir: Effortless Directory Removal Guide

Advanced Options of `mkdir`

Creating Nested Directories

Nested directories are a practical way to keep related files organized. If you wish to create directories within each other, the syntax is:

mkdir Parent\Child\Grandchild

This command will create a hierarchy where Parent contains Child, and Child contains Grandchild. This is exceptionally useful for projects with a structured format.

Using the `/p` Parameter

The `/p` parameter allows users to create nested directories even if some parent directories do not yet exist. Here’s how it works:

mkdir Parent\Child\Grandchild /p

This command will create the entire path, including Parent, Child, and Grandchild, regardless of whether the parent directories already exist. It ensures that you can create a complete structure in one go, reducing the need for multiple commands.

Mastering Cmd Dir List for Quick Directory Insights

Mastering Cmd Dir List for Quick Directory Insights

Error Handling with `mkdir`

Common Errors and Solutions

While using `mkdir`, users may encounter common errors. Understanding these can save time and frustration.

For instance, if you try to create a directory in a non-existent path, you might see the error:

The system cannot find the path specified.

To resolve this, double-check the path before executing the command. Ensure that each parent directory in the intended path exists unless you are using the `/p` option.

Mastering Cmd Md: A Quick Guide to Cmd Mastery

Mastering Cmd Md: A Quick Guide to Cmd Mastery

Best Practices for Using `mkdir`

Naming Conventions

When creating directories, clear and descriptive names aid in navigation and organization. Avoid using spaces and special characters to ensure compatibility across different systems and software. For instance, prefer ProjectFiles over Project Files.

Organizing Directories

Effective organization is essential for productivity. Before creating directories, take a moment to plan the structure. Consider how files will be used, and create top-level directories that make logical sense for your projects.

Mastering Cmd Disklist: Your Quick Guide to Disk Management

Mastering Cmd Disklist: Your Quick Guide to Disk Management

Examples of Practical Uses

Structuring a Project Directory

Let’s say you have a new project and need to organize your files efficiently. You might run the following command:

mkdir Project\Source Project\Docs Project\Assets

This way, you create a logical structure where Source, Docs, and Assets fall under the Project directory. Each directory can serve a unique purpose, simplifying file retrieval and management.

Creating Directories for Scripting

For those interested in automation, using `mkdir` in batch files can significantly speed up the setup of a workspace. For example, a simple batch script might look like this:

@echo off
mkdir Project\{Source,Docs,Assets}

This enables the rapid creation of a project structure every time you need to start a new project, illustrating the power of integrating `mkdir` with scripting.

Mastering Cmd DISM: Your Quick Guide to Deployment

Mastering Cmd DISM: Your Quick Guide to Deployment

Conclusion

The `mkdir` command is a versatile and essential tool in the command line arsenal for any Windows user. By mastering this command, you can streamline your directory creation process, enhance your organizational skills, and ultimately become more efficient in your workflows. With practice, you’ll find the countless opportunities to implement `mkdir` into your daily tasks. For those eager to expand their command line knowledge, delving deeper into CMD commands will open up a wider world of efficiency and control.

Mastering Cmd Kill: A Quick Guide to Terminating Processes

Mastering Cmd Kill: A Quick Guide to Terminating Processes

Additional Resources

For further learning, consider exploring resources on CMD commands, scripting tutorials, and best practices for directory management. Continual learning will enhance your command line proficiency and boost your productivity in dealing with technology.

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Download Article

Download Article

Learning how to do simple file management at the Command Prompt (cmd) comes in handy when you’re learning to code. When you create files and folders at the command line, you can access, use, and manipulate those folders and files in Windows apps. We’ll show you how to create folders (directories) and text files at the Windows Command Prompt, and teach you commands for deleting unneeded files and folders.

  1. Step 1 Open the Command...

    Open the Command Prompt. The easiest way to do this is to press Win + S to activate the search bar, type cmd, and then click Command Prompt in the search results.

  2. Step 2 Go to the directory in which you want to create the file.

    The prompt will open to C:\Users\YourName by default. If the directory is somewhere else, type cd path_to_directory and press Enter. Replace path_to_directory with the actual directory location.[1]

    • For example, if you want to create a file on the Desktop, type cd desktop and press Enter.
    • If the directory you’re looking for isn’t in your user directory (e.g., C:\Users\YourName), you’ll have to type in the whole path (e.g., C:\Users\SomeoneElse\Desktop\Files).

    Advertisement

  3. Step 3 Create an empty file.

    If you don’t want to create an empty file, skip to the next step.[2]
    To create an empty file:

    • Type type nul > filename.txt.
    • Replace filename.txt with whatever you want to call your new file. The «.txt» part indicates that this is a plain text file. Other common file extensions include «.docx» (Word document), «.png» (empty photo),and «.rtf» (rich text document). All of these file types can be read on any Windows computer without installing additional software.
    • Press Enter.
  4. Step 4 Create a file containing certain text.

    If you don’t want to create a file with certain text inside, skip to the next step.[3]
    Use these steps to create a plain text file that you can type into:

    • Type copy con testfile.txt, but replace testfile with the desired file name.[4]
    • Press Enter.
    • Type some text. This is a rudimentary text editor, but it’s good for quick notes or code. You can use the Enter key to go to the next line.
    • Press Control + Z when you’re finished editing the file.
    • Press the Enter key. You’ll see «1 file(s) copied,» which means your file is now saved with the name you created.
    • Another way to do this is to run this command: echo enter your text here > filename.txt.
  5. Step 5 Create a file that's a certain size.

    If you don’t want to create a file that’s a specific size, skip this step.[5]
    To create a blank text file based on byte size, use this command:

    • fsutil file createnew filename.txt 1000.
    • Replace filename with the desired file name, and 1000 with the actual number of bytes you’d like the file to be.
  6. Advertisement

  1. Step 1 Open the Command Prompt.

    The easiest way to do this is to press Win + S to activate the search bar, type cmd, and then click Command Prompt in the search results.

  2. Step 2 Go to the...

    Go to the directory containing the file you want to delete. The prompt will open to C:\Users\YourName by default. If the file is somewhere else, type cd path_to_directory and press Enter. Replace path_to_directory with the actual directory location.

    • For example, if you want to delete a file from the Desktop, type cd desktop and press Enter.
    • If the directory you want to view isn’t in your user directory (e.g., C:\Users\YourName), you’ll have to type in the whole path (e.g., C:\Users\SomeoneElse\Desktop\Files).
  3. Step 3 Type dir and press ↵ Enter.

    This displays a list of all files in the current directory. You should see the file you want to delete in this list.

    • Using Command Prompt to delete files results in the files being deleted permanently rather than being moved to the Recycle Bin. Exercise caution when deleting files via Command Prompt.
  4. Step 4 Type del filename and press ↵ Enter.

    Replace filename with the full name and extension of the file you want to delete.[6]
    File names include file extensions (e.g., *.txt, *.jpg). This deletes the file from your computer.

    • For example, to delete a text file entitled «hello», you would type del hello.txt into Command Prompt.
    • If the file’s name has a space in it (e.g., «hi there»), you will place the file’s name in quotations (e.g., del "hi there").
    • If you get an error that says the file cannot be deleted, try using del /f filename instead, as this force-deletes read-only files.
  5. Advertisement

  1. Step 1 Open the Command Prompt.

    The easiest way to do this is to press Win + S to activate the search bar, type cmd, and then click Command Prompt in the search results.[7]

  2. Step 2 Go to the directory in which you want to create the new directory.

    The prompt will open to C:\Users\YourName by default. If you don’t want to create a new directory here, type cd path_to_directory and press Enter. Replace path_to_directory with the actual directory location.[8]

    • For example, if you want to create a directory on your Desktop, you would type in cd desktop and press Enter.
    • If the directory you’re looking for isn’t in your user directory (e.g., C:\Users\YourName), you’ll have to type in the whole path (e.g., C:\Users\SomeoneElse\Desktop\Files).
  3. Step 3 Type mkdir NameOfDirectory at the prompt.

    Replace NameOfDirectory with the name of the directory you wish to create.[9]

    • For example, to make a directory named «Homework», you would type mkdir Homework.
  4. Step 4 Press ↵ Enter.

    This runs the command to create a folder with the desired name.

  5. Advertisement

  1. Step 1 Open the Command Prompt.

    The easiest way to do this is to press Win + S to activate the search bar, type cmd, and then click Command Prompt in the search results.[10]

  2. Step 2 Go to the folder containing the directory you want to delete.

    The prompt will open to C:\Users\YourName by default. If the directory you want to delete is somewhere else, type cd path_to_directory and press Enter.[11]
    Replace path_to_directory with the actual directory location.

    • For example, if you want to delete a directory from your Desktop, type cd desktop.
    • If the directory isn’t in your user directory (e.g., C:\Users\YourName), you’ll have to type in the whole path (e.g., C:\Users\SomeoneElse\Desktop\Files).
  3. Step 3 Type rmdir /s DirectoryName.

    Replace DirectoryName with the name of the directory you want to delete.[12]

    • For example, if you’re trying to delete your «Homework» folder, you’d type in rmdir /s Homework here.
    • If the directory’s name has a space in it (e.g., «Homework assignments»), place the name in quotations (e.g., rmdir /s "Homework assignments").
  4. Step 4 Press ↵ Enter to run the command.

    [13]

    • If you try to delete a directory that contains hidden files or directories, you’ll see an error that says «The directory is not empty.» In this case, you’ll have to remove the «hidden» and «system» attributes from the files inside the directory. To do this:[14]

      • Use cd to change into the directory you want to delete.
      • Run dir /a to view a list of all files in the directory and their attributes.
      • If you’re still okay with deleting all of the files in the directory, run attrib -hs *. This removes special permissions from the undeletable files.
      • Type cd .. and press Enter to go back one directory.
      • Run the rmdir /s command again to delete the folder.
  5. Step 5 Press y and then ↵ Enter to confirm.

    This will permanently remove the directory.[15]

  6. Advertisement

Add New Question

  • Question

    How can I create directories?

    Subhodeep Roy

    Community Answer

    If you are creating a directory in C drive, the command will be»C:\MD {the name of the directory/folder}» then press Enter.

  • Question

    How do I create a folder using CMD?

    Navigate to where you want the subfolder created and type «mkdir «.

  • Question

    How do I create a test file under the sub folder?

    Change directory into the new sub folder and then on the next line, create your new test file. For example: cd mysubfolder $ type nul > newtextfile.txt

See more answers

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Submit

Advertisement

Video

Thanks for submitting a tip for review!

  • Using Command Prompt to delete files results in the files being deleted permanently rather than being moved to the Recycle Bin. Exercise caution when deleting files via Command Prompt.

Advertisement

References

About This Article

Article SummaryX

1. Use the mkdir command to create a folder.
2. Use rmdir /s to delete a folder.
3. Use the copy con or echo command to create a file.
4. Use del to delete a file.
For tips on how to create a file inside a folder, read on!

Did this summary help you?

Thanks to all authors for creating a page that has been read 1,585,483 times.

Is this article up to date?

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Aida64 windows 10 64 bit официальный сайт
  • При установке windows xp вылезает синий экран
  • Windows 7 ultimate лайт
  • Windows 10 21h2 ltsc key
  • Как узнать версию windows если система не грузится