• About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy Policy
  • Change the purpose of use

Tnhelearning.edu.vn - Various useful general information portal

  • Photo
  • Bio
  • How To
  • Tech

How to Create and Delete Files or Folders from Windows Command Prompt

January 25, 2024 by admin Category: How To

You are viewing the article How to Create and Delete Files or Folders from Windows Command Prompt  at Tnhelearning.edu.vn you can quickly access the necessary information in the table of contents of the article below.

X

This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

This article has been viewed 41,397 times.

This is an article that shows you how to use Command Prompt on Windows to create and delete files and folders (also known as directories). Files that you create from the Command Prompt can be edited and managed using Windows applications, including File Manager and text editors.

Table of Contents

  • Steps
    • Create folder
    • Delete folder
    • Create file
    • Delete files
  • Warning

Steps

Create folder

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 1

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 1

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/c/c6/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-1-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-1-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/c/c6/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-1-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-1-Version-2.jpg”,”smallWidth”:460,”smallHeight”:347,”bigWidth”:728,”bigHeight”:549 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Open Command Prompt in two quick ways:

  • Right-click the Start menu and select Command Prompt .
  • Press ⊞ Win + S to open the search bar, type cmd , and then click Command Prompt in the search results.
Image titled Create and Delete Files and Directories from Windows Command Prompt Step 2

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/91/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/9/91/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Access the required folder. The Command Prompt window will display the command C:Users Your name by default. If you don’t want to create a new directory here, type cd path_to_fpder and press ↵ Enter . Replace path_to_fpder with the path of the directory.

  • For example, if you wanted to create a folder on the Desktop, you would type cd desktop and press ↵ Enter .
  • If the directory is not in the user directory (such as C:Users Your Name ), you will have to enter the path (e.g. C:UsersNameDesktopFiles ).
Image titled Create and Delete Files and Directories from Windows Command Prompt Step 3

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 3

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/4e/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-3-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-3-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/4/4e/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-3-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-3-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Type mkdir NamOfFpder into the Command Prompt. Replace NameOfFpder with the name of the folder you want to create.

  • For example, to create a folder named “Homework”, you would type mkdir Homework .
Image titled Create and Delete Files and Directories from Windows Command Prompt Step 4

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 4

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/49/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-4-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-4-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/4/49/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-4-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-4-Version-2.jpg”,”smallWidth”:460,”smallHeight”:342,”bigWidth”:728,”bigHeight”:541 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Press ↵ Enter . This is the operation that asks the Command Prompt to create a folder with the name you want.

Delete folder

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 1

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 1

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/c/c6/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-1-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-1-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/c/c6/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-1-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-1-Version-2.jpg”,”smallWidth”:460,”smallHeight”:347,”bigWidth”:728,”bigHeight”:549 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Open Command Prompt in two quick ways:

  • Right-click the Start menu and select Command Prompt .
  • Press ⊞ Win + S to open the search bar, type cmd and click Command Prompt in the search results.
READ More:   How to Apply the No Contact Rule
Image titled Create and Delete Files and Directories from Windows Command Prompt Step 2

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/91/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/9/91/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Go to the folder containing the folder you want to delete. The Command Prompt window will display the command C:Users Your name by default. If you wanted to delete another folder, you would type cd path_to_fpder and press ↵ Enter . Replace path_to_fpder with the path of the directory.

  • For example, if you want to delete a folder from the Desktop, type cd desktop .
  • If the directory is not in the user directory (such as C:Users Your Name ), you will have to enter the entire path (e.g. C:UsersNameDesktopFiles ).
Image titled Create and Delete Files and Directories from Windows Command Prompt Step 12

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 12

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/b4/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-12-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-12-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/b/b4/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-12-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-12-Version-2.jpg”,”smallWidth”:460,”smallHeight”:342,”bigWidth”:728,”bigHeight”:541 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Type rmdir /s FpderName . Replace FpderName with the name of the folder you want to delete. [1] X Research Source

  • For example, if you wanted to delete the “Homework” directory, you would enter rmdir /s Homework here.
  • If the folder name contains spaces (such as “Homework assignments”), enclose the name in quotes (e.g. rmdir /s "Homework assignments" ).
Image titled Create and Delete Files and Directories from Windows Command Prompt Step 13

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 13

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/d3/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-13.jpg/ v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-13.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ d/d3/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-13.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows- Command-Prompt-Step-13.jpg”,”smallWidth”:460,”smallHeight”:342,”bigWidth”:728,”bigHeight”:541,”licensing”:”<div class=”mw-parser-output “></div>”}
Press ↵ Enter to execute the command.

  • If you want to delete a folder that contains hidden files or folders, you will see the error message “The directory is not empty”. In this case, you will have to remove the “hidden” and “system” attributes of the files inside the directory. Do the following: [2] X Research Sources
    • Use cd to change to the directory you want to delete.
    • Execute the command dir /a to see a list of all files in the directory and their properties.
    • If you still cannot delete all files in the directory, execute the command attrib -hs * . This is a special access removal operation from files that cannot be deleted.
    • Type cd .. and press ↵ Enter to return to the previous directory.
    • Execute the command rmdir /s again to delete the directory.
Image titled Create and Delete Files and Directories from Windows Command Prompt Step 14

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 14

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/8f/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-14.jpg/ v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-14.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 8/8f/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-14.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows- Command-Prompt-Step-14.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output “></div>”}
Press y to confirm. This will delete the folder permanently.

Create file

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 5

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 5

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/da/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-5-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-5-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/d/da/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-5-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-5-Version-2.jpg”,”smallWidth”:460,”smallHeight”:347,”bigWidth”:728,”bigHeight”:549 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Open Command Prompt in two quick ways:

  • Right-click the Start menu and select Command Prompt .
  • Press ⊞ Win + S to open the search bar, type cmd and then click Command Prompt in the search results.
Image titled Create and Delete Files and Directories from Windows Command Prompt Step 2

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/91/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/9/91/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Go to the folder where you want to create the file. The Command Prompt window will display the command C:Users Your name by default. If you wanted to use a different directory, you would type cd path_to_fpder and press ↵ Enter . Replace path_to_fpder with the path of the directory.

  • For example, if you want to create a file on the Desktop, type cd desktop and press ↵ Enter .
  • If the directory is not in the user directory (such as C:Users Your Name ), you will have to enter the entire path (e.g. C:UsersNameDesktopFiles ).
READ More:   How to Cheat in Cookie Clicker Online game
Image titled Create and Delete Files and Directories from Windows Command Prompt Step 8

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 8

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/a7/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-8-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-8-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/a/a7/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-8-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-8-Version-2.jpg”,”smallWidth”:460,”smallHeight”:343,”bigWidth”:728,”bigHeight”:543 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Create empty files in any format. If you don’t want to create an empty file, go to the next step. Empty files will be created in the following way:

  • Type type nul > filename.txt .
  • Replace filename.txt with the filename and extension you like. Other common extensions include “.docx” (Word document), “.png” (empty image file), “.xlsx” (Excel document), and “.rtf” (for text) basic format).
  • Press ↵ Enter .
Create text file. If you do not want to create a text file, proceed to the next step. Use the following steps to create a raw text file that you can import:

  • Type copy con testfile .txt , but replace testfile with the filename you like.
  • Press ↵ Enter .
  • Enter the content you like. This is a rudimentary text editor, but still effective for coding or taking quick notes. You can use the Enter key while editing to enter text on the next line if you like.
  • Press Ctrl + Z when you are done editing the file. This is the operation to save all the content entered into the file.
  • Another way to do this is to enter the echo command here > filename .txt .
Create a file of any size. If you don’t want to size the file, skip this step. To create an empty file in byte size, you would execute the following command:

  • fsutil file createnew filename .txt 1000 .
  • Replace filename with the name you want, and replace 1000 with the number of bytes to create for the file.

Delete files

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 5

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 5

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/da/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-5-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-5-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/d/da/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-5-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-5-Version-2.jpg”,”smallWidth”:460,”smallHeight”:347,”bigWidth”:728,”bigHeight”:549 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Open Command Prompt in two quick ways:

  • Right-click the Start menu and select Command Prompt .
  • Press ⊞ Win + S to open the search bar, type cmd and then click Command Prompt in the search results.
Image titled Create and Delete Files and Directories from Windows Command Prompt Step 2

Image titled Create and Delete Files and Directories from Windows Command Prompt Step 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/91/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version- 2.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg”,”bigUrl”:”https://www. wikihow.com/images/thumb/9/91/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg/v4-728px-Create-and- Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-2-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546 ,”licensing”:”<div class=”mw-parser-output”></div>”}
Go to the folder containing the file you want to delete. The Command Prompt window will display the command C:Users Your name by default. If you wanted to use a different directory, you would type cd path_to_fpder and press ↵ Enter . Replace path_to_fpder with the path of the directory.

  • For example, if you want to create a file on the Desktop, type cd desktop and press ↵ Enter .
  • If the directory is not in the user directory (such as C:Users Your Name ), you will have to enter the entire path (e.g. C:UsersNameDesktopFiles ).
READ More:   How to Use Aloe Vera for Face
Type dir and press ↵ Enter to open a list of all files in the current directory. You will see the file you want to delete in this list.

  • Files deleted using Command Prompt will be permanently deleted instead of being moved to the Recycle Bin. Therefore, you should be very careful when deleting files using Command Prompt.
  • Image titled Create and Delete Files and Directories from Windows Command Prompt Step 17

    Image titled Create and Delete Files and Directories from Windows Command Prompt Step 17

    {“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/42/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-17.jpg/ v4-728px-Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-17.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 4/42/Create-and-Delete-Files-and-Directories-from-Windows-Command-Prompt-Step-17.jpg/v4-728px-Create-and-Delete-Files-and-Directories-from-Windows- Command-Prompt-Step-17.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,”bigHeight”:550,”licensing”:”<div class=”mw-parser-output “></div>”}
    Type del filename and press ↵ Enter . Replace filename with the full name and extension of the file you want to delete. The filename includes the file’s extension (such as *.txt, *.jpg). This will delete the file from your computer.

    • For example, to delete a text file named “hello”, you would type del hello.txt into the Command Prompt.
    • If the filename has spaces (eg “hi there”), enclose the filename in quotes (such as del "hi there" ).
    • If you get a message that the file cannot be deleted, use the command del /f filename instead , as this command is used to delete read-only files.
  • Warning

    • Files deleted using Command Prompt will be permanently deleted instead of being moved to the Recycle Bin. Therefore, you should be very careful when deleting files using Command Prompt.
    X

    This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

    The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

    This article has been viewed 41,397 times.

    This is an article that shows you how to use Command Prompt on Windows to create and delete files and folders (also known as directories). Files that you create from the Command Prompt can be edited and managed using Windows applications, including File Manager and text editors.

    Thank you for reading this post How to Create and Delete Files or Folders from Windows Command Prompt at Tnhelearning.edu.vn You can comment, see more related articles below and hope to help you with interesting information.

    Related Search:

    Related Posts

    How to Create Curved Text in Photoshop
    How to fall asleep faster
    How to Install FBReader to Read eBooks

    Category: How To

    Previous Post: « How to make rich fried pork heart with melon for a simple meal
    Next Post: How to make hot and spicy spicy cheese fried bulot snails »

    Copyright © 2025 · Tnhelearning.edu.vn - Useful Knowledge