Janna Theme License is not validated, go to the theme options page to validate the license, you need a single license for each domain name.

How to create a folder or file using the Windows command prompt

The Windows Command Prompt (CMD) is a powerful tool for running commands and performing various tasks on your computer. One of its primary functions is creating folders and files from the command line. In this article, we'll explore how to create a folder or file using the Windows Command Prompt. However, let's first understand why you might want to use CMD for this purpose.

Create-a-Folder-or-File-from-Windows-Command-Prompt_1-1536x864-1 How to Create a Folder or File Using the Windows Command Prompt

Creating folders or files using the Command Prompt can be useful for several reasons. One of the most common is managing remote computers or servers through command-line interfaces and quickly creating a folder or file without navigating through the graphical interface.

Now that we know the benefits of creating folders and files using CMD, let's continue the article to learn how to do it effectively using command line commands.

How to Create Folders from CMD in Windows

Creating folders using CMD in Windows may seem difficult, but it's not. The steps are very simple and straightforward to follow. We've separated the steps based on whether you're creating a single folder or multiple folders.

Let's start with the command line for a new folder.

How to create a single folder using CMD

Step 1: press the . key Windows On the keyboard, type Command Prompt, then tap to open.

Create-a-Folder-or-File-from-Windows-Command-Prompt_11 How to Create a Folder or File Using the Windows Command Prompt

Step 2: Now, it's time to specify the destination where you want to create the new folder. Type the command below and press Enter.

Note: Instead of YourDirectoryPath below, enter the specific destination path. For example, if you want to create a folder on the Desktop, type cd Desktop and press Enter.

cd YourDirectoryPath

Create-a-Folder-or-File-from-Windows-Command-Prompt_9 How to Create a Folder or File Using the Windows Command Prompt

If you change your mind and want to change the directory, type the drive name using a colon (:) (example – D:) and then press Enter.

Also read:  Fix "The requested operation requires an upgrade" error - Error 740 in Windows 10

Step 3: Once you reach the desired destination, type the command below and press Enter.

Note: Replace NameofYourDirectory with the name of the folder (for example, Games, Profiles, Movies, etc.)

mkdir NameofYourDirectory

Create-a-Folder-or-File-from-Windows-Command-Prompt_5 How to Create a Folder or File Using the Windows Command Prompt That's it. You've successfully created a single folder on your Windows computer using the Command Prompt. If you're looking to create multiple folders or subfolders, read on.

How to create multiple folders or subfolders

We'll show you how to create three folders at the same time. However, you can create as many folders as you like, as long as they have different folder names.

Step 1: Press the Windows key on your keyboard, and type Command Prompt, then tap to open.

Create-a-Folder-or-File-from-Windows-Command-Prompt_11 How to Create a Folder or File Using the Windows Command Prompt

Step 2: Now, it's time to specify the destination where you want to create the new folder. Type the command below and press Enter.

Note: Instead of YourDirectoryPath below, enter the specific destination path. For example, if you want to create a folder on the Desktop, type cd Desktop and press Enter.

cd YourDirectoryPath

Create-a-Folder-or-File-from-Windows-Command-Prompt_9 How to Create a Folder or File Using the Windows Command Prompt

If you change your mind and want to change the directory, type the drive name using a colon (:) (example – D:) and then press Enter.

Step 3: Once you reach the desired destination, type the command below and press Enter.

Note: Replace NameofYourDirectory with the folder name. For example, it could be Games, Documents, and Movies. Make sure to leave a space between folder (directory) names.

mkdir NameofYourDirectory1 NameofYourDirectory2 NameofYourDirectory3

Create-a-Folder-or-File-from-Windows-Command-Prompt_4 How to Create a Folder or File Using the Windows Command Prompt

There you go. You've successfully created a folder using the Windows Command Prompt. Follow the steps below if you want to create a subdirectory using CMD.

Also read:  Fix a Stuck or Frozen Windows 10 Update

Step 4: Find out the names of the folders you created. First, select the folder you want to create subfolders in, type the command below, and then press Enter.

cd NameofYourDirectory

Create-a-Folder-or-File-from-Windows-Command-Prompt_10 How to Create a Folder or File Using the Windows Command Prompt

Step 5: In the directory where you want to create subfolders, type the following command and press Enter. Enter.

Note: You can have multiple subfolders within a single folder. However, be sure to leave a gap between the folder (directory) name.

md NameofSubDirectory1 NameofSubDirectory2 NameofSubDirectory3

Create-a-Folder-or-File-from-Windows-Command-Prompt_8 How to Create a Folder or File Using the Windows Command Prompt That's it. Subfolders are created within the folder you want. You can repeat the steps above to create multiple subfolders within multiple folders.

Keep reading if you want to go ahead and create a cmd file.

How to create a file using CMD in Windows

Much like creating a folder using the command prompt, creating a file in CMD is no different, provided you understand the basics of finding and locating the destination directory and naming the file clearly.

Let's start by creating an empty file using the Windows command prompt.

How to create an empty file

Step 1: Press the Windows key on your keyboard, and type Command Prompt, then tap to open.

Create-a-Folder-or-File-from-Windows-Command-Prompt_11 How to Create a Folder or File Using the Windows Command Prompt

Step 2: Now, it's time to specify the destination where you want to create the new folder. Type the command below and press Enter.

Note: Instead of YourDirectoryPath below, enter the specific destination path. For example, if you want to create a folder on the Desktop, type cd Desktop and press Enter.

cd YourDirectoryPath

Create-a-Folder-or-File-from-Windows-Command-Prompt_9 How to Create a Folder or File Using the Windows Command Prompt

Step 3: Now that you are in the destination directory, type the command below and press Enter. Enter.

Note: Replace the file name with your desired name, and “.FileExtensions” must be assigned to the file extension, such as .txt, .docx, etc.

type nul > filename.FileExtensions

Create-a-Folder-or-File-from-Windows-Command-Prompt_3 How to Create a Folder or File Using the Windows Command Prompt

That's all. An empty file with the group extension will be created for you to check and work with later. If you want to create a file with some text using cmd, read on.

How to create a file containing some text

Step 1: Press the Windows key on your keyboard, and type Command Prompt, then tap to open.

Also read:  Fix: Windows keeps automatically adding the EN-US keyboard layout in Windows 10

Create-a-Folder-or-File-from-Windows-Command-Prompt_11 How to Create a Folder or File Using the Windows Command Prompt

Step 2: Now, it's time to specify the destination where you want to create the new folder. Type the command below and press Enter.

Note: Instead of YourDirectoryPath below, enter the specific destination path. For example, if you want to create a folder on the Desktop, type cd Desktop and press Enter.

cd YourDirectoryPath

Create-a-Folder-or-File-from-Windows-Command-Prompt_9 How to Create a Folder or File Using the Windows Command Prompt Step 3: Now, in the destination directory, type the below command and press Enter. Enter.

Note: Replace the file name with your desired name, and “.FileExtensions” must be assigned to the file extension, such as .txt, .docx, etc.

copy con filename. FileExtensions

Create-a-Folder-or-File-from-Windows-Command-Prompt_7 How to Create a Folder or File Using the Windows Command Prompt

Step 4: Type the text you want to place in the file. If you are entering multiple lines, use the key. Enter.

Example: This is a test script to test the method and create a file containing content using the command prompt.

Create-a-Folder-or-File-from-Windows-Command-Prompt_6 How to Create a Folder or File Using the Windows Command Prompt Step 5: Click on Ctrl + Z On your keyboard once you have added text to the file and press Enter.

Create-a-Folder-or-File-from-Windows-Command-Prompt_2 How to Create a Folder or File Using the Windows Command Prompt

This will create a new file with the entered details, which you can access via File Explorer and further modify if necessary. If, for some reason, you are unable to execute the command, contactMicrosoft Support And solve the problem.

If there is anything we missed in the article, please refer to the FAQ section below.

common questions:

Q1. How can I delete a folder using Command Prompt?
The answer: To delete a folder and its contents, use the “rmdir” (remove directory) command followed by the folder path. For example:

rmdir /s /q C:\Users\YourUsername\Desktop\OldFolder

Q2. What is the difference between “rmdir” and “rd” commands?
The answer: Both "rmdir" and "rd" are used to remove directories. "Rmdir" is the full command, while "rd" is a shortened version. You can use either command interchangeably.

Q3. Can I recover a folder I accidentally deleted using Command Prompt?
The answer: Once you delete a folder using the Command Prompt, it usually goes to the Recycle Bin, where you can recover it. If you empty the Recycle Bin, data recovery software may be necessary to attempt recovery.

Quickly create a file or folder

Now that you know how to create a folder or file using the Windows Command Prompt, you can quickly automate tasks, manage remote systems, create files, or improve your command-line efficiency. You may also want to Close all open applications at once on Windows 11.

Go to top button