Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Create and Delete Files and Directories from Windows

Learn how to create and delete files and directories from Windows with clear steps, practical context, and useful troubleshooting guidance.

Table of Contents

This updated guide examines How to Create and Delete Files and Directories from Windows and organizes the essential facts, background, and practical takeaways in clear American English.

Method 1of 4:

Creating a Folder

  1. How to Create and Delete Files and Directories from Windows — contextual image 1 Open the Command Prompt. Here are two quick ways to do so:
    • Right-click the Start menu and select Command Prompt .
    • Press?Win+Sto open the search bar, typecmd, and then click Command Prompt in the search results.
  2. How to Create and Delete Files and Directories from Windows — contextual image 2 Go to the desired folder. The prompt will open to C:Users YourName by default. If you don't want to create a new folder here, typecd path_to_folder and press?Enter. Replace path_to_folder with the actual folder location.
    • For example, if you want to create a folder on your Desktop, folder, you would type incd desktopand press?Enter.
    • If the folder isn't in your user directory (e.g., C:Users YourName ), you'll have to type in the whole path (e.g.,C:UsersSomeoneElseDesktopFiles).
  3. How to Create and Delete Files and Directories from Windows — contextual image 3 Typemkdir NameOfFolder at the prompt. Replace NameOfFolder with the name of the folder you wish to create.
    • For example, to make a directory named "Homework", you would typemkdir Homework.
  4. How to Create and Delete Files and Directories from Windows — contextual image 4 Press?Enter. This runs the command to create a folder with the desired name.

Method 2of 4:

Deleting a Folder

  1. How to Create and Delete Files and Directories from Windows — contextual image 5 Open the Command Prompt. Here are two quick ways to do so:
    • Right-click the Start menu and select Command Prompt .
    • Press?Win+Sto open the search bar, typecmd, and then click Command Prompt in the search results.
  2. How to Create and Delete Files and Directories from Windows — contextual image 6 Go to the folder containing the folder you want to delete. The prompt will open to C:Users YourName by default. If the folder you want to delete is somewhere else, typecd path_to_folder and press?Enter. Replace path_to_folder with the actual folder location.
    • For example, if you want to delete a folder from your Desktop, typecd desktop.
    • If the folder isn't in your user directory (e.g., C:Users YourName ), you'll have to type in the whole path (e.g.,C:UsersSomeoneElseDesktopFiles).
  3. How to Create and Delete Files and Directories from Windows — contextual image 7 Typermdir /s FolderName . Replace FolderName with the name of the folder you want to delete.[1]
    • For example, if you're trying to delete your "Homework" folder, you'd type inrmdir /s Homeworkhere.
    • If the folder's name has a space in it (e.g., "Homework assignments"), place the name in quotations (e.g.,rmdir /s "Homework assignments").
  4. How to Create and Delete Files and Directories from Windows — contextual image 8 Press?Enterto run the command.
    • If you try to delete a directory that contains hidden files or folders, 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 folder. To do this:[2]
      • Usecdto change into the directory you want to delete.
      • Rundir /ato 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 folder, runattrib -hs *. This removes special permissions from the undeletable files.
      • Typecd..and press?Enterto go back one directory.
      • Run thermdir /scommand again to delete the folder.
  5. How to Create and Delete Files and Directories from Windows — contextual image 9 Pressyto confirm. This will permanently remove the directory.

Method 3of 4:

Creating a File

  1. How to Create and Delete Files and Directories from Windows — contextual image 10 Open the Command Prompt. Here are two quick ways to do this:
    • Right-click the Start menu and select Command Prompt .
    • Press?Win+Sto open the search bar, typecmd, and then click Command Prompt in the search results.
  2. How to Create and Delete Files and Directories from Windows — contextual image 11 Go to the folder in which you want to create the file. The prompt will open to C:Users YourName by default. If the folder is somewhere else, typecd path_to_folder and press?Enter. Replace path_to_folder with the actual folder location.
    • For example, if you want to create a file on the Desktop, typecd desktopand press?Enter.
    • If the folder isn't in your user directory (e.g., C:Users YourName ), you'll have to type in the whole path (e.g.,C:UsersSomeoneElseDesktopFiles).
  3. How to Create and Delete Files and Directories from Windows — contextual image 12 Create an empty file of any type. If you don't want to create an empty file, skip to the next step. To create an empty file:
    • Typetype nul > filename.txt .
    • Replace filename.txt with the desired file name and extension. Other common file extensions include ".docx" (Word document), ".png" (empty photo), ".xlsx" (Excel document), and ".rtf" (rich text document).
    • Press?Enter.
  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. Use these steps to create a plain text file that you can type into:
    • Typecopy con testfile .txt, but replace testfile with the desired file name.
    • Press?Enter.
    • Type your desired text. This is rudimentary text editor, but it's good for quick notes or code. You can use theEnterkey as you type to move to the next line if you wish.
    • PressCtrl+Zwhen you're finished editing the file. This saves everything you've typed into the file.
    • Another way to do this is to run this command:echo enter your text here > filename .txt.
  5. Create a file that's a certain size. If you don't want to create a file that's a specific size, skip thi step. To create a blank 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.

Method 4of 4:

Deleting a File

  1. How to Create and Delete Files and Directories from Windows — contextual image 13 Open the Command Prompt. Here are two quick ways to do this:
    • Right-click the Start menu and select Command Prompt .
    • Press?Win+Sto open the search bar, typecmd, and then click Command Prompt in the search results.
  2. How to Create and Delete Files and Directories from Windows — contextual image 14 Go to the folder containing the file you want to delete. The prompt will open to C:Users YourName by default. If the file is somewhere else, typecd path_to_folder and press?Enter. Replace path_to_folder with the actual folder location.
    • For example, if you want to delete a file from the Desktop, typecd desktopand press?Enter.
    • If the folder isn't in your user directory (e.g., C:Users YourName ), you'll have to type in the whole path (e.g.,C:UsersSomeoneElseDesktopFiles).
  3. Typedirand press?Enter. This displays a list of all files in the current folder. 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. How to Create and Delete Files and Directories from Windows — contextual image 15 Typedel filename and press?Enter. Replace filename with the full name and extension of the file you want to delete. 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 typedel hello.txtinto 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 usingdel /f filename instead, as this force-deletes read-only files.

FAQ

What is How to Create and Delete Files and Directories from Windows about?

It provides a structured overview of file, explains the main context, and highlights practical takeaways for readers.

Why does this topic matter?

Understanding the main concepts helps readers evaluate the issue, avoid common mistakes, and make better-informed decisions.

How should readers use this information?

Use the guidance as a practical starting point, confirm details that may have changed, and follow current product, safety, or security recommendations.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.