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

Create folder

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

Open Command Prompt in two quick ways:

Right-click the Start menu and select Command Prompt .

Press ⊞ Win+ Sto open the search bar, type cmd, then click Command Prompt in the search results.

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

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 folder here, type and press . Replace path_to_folder with the folder's path.cd path_to_folder ↵ Enter

For example, if you want to create a folder on the Desktop, you would type cd desktopand press ↵ Enter.

If the directory is not in the user directory (such as C:Users Your Name ), you will have to enter the path as well (for example: C:UsersTênDesktopFiles).

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

Enter Command Prompt.mkdir NamOfFolder Replace NameOfFolder with the name of the folder you want to create.

For example, to create a folder named "Homework", you would enter mkdir Homework.

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

Press ↵ Enter. This tells Command Prompt to create a folder with the name you want.

Delete folder

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

Open Command Prompt in two quick ways:

Right-click the Start menu and select Command Prompt .

Press ⊞ Win+ Sto open the search bar, type cmdand click Command Prompt in the search results.

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

Access 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 want to delete another folder, you will enter and press . Replace path_to_folder with the folder's path.cd path_to_folder ↵ Enter

For example, if you want to delete a folder from the Desktop, enter 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:UsersTênDesktopFiles).

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

Import .rmdir /s FolderName Replace FolderName with the name of the folder you want to delete.

For example, if you want to delete the "Homework" folder, you would enter it rmdir /s Homeworkhere.

If the folder name contains spaces (such as "Homework assignments"), you would enclose the name in quotation marks (for example: rmdir /s "Homework assignments").

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

Press ↵ Enterto 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 delete the "hidden" and "system" attributes of the files inside the folder. Do the following:

Used cdto change the folder you want to delete.

Execute the command dir /ato view a list of all files in the directory and their properties.

If you still cannot delete all the files in the directory, execute the command attrib -hs *. This removes special access permissions from files that cannot be deleted.

Enter cd .and press ↵ Enterto return to the previous folder.

Execute the command rmdir /sagain to delete the folder.

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

Press yto confirm. This will delete the folder permanently.

Create file

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

Open Command Prompt in two quick ways:

Right-click the Start menu and select Command Prompt .

Press ⊞ Win+ Sto open the search bar, type cmdthen click Command Prompt in the search results.

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

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 want to use another folder, you will enter and press . Replace path_to_folder with the folder's path.cd path_to_folder ↵ Enter

For example, if you want to create a file on the Desktop, enter cd desktopand 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:UsersTênDesktopFiles).

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

Create empty files in any format. If you don't want to create an empty file, go to the next step. The empty file will be created in the following way:

Type type nul > filename.txt .

Replace filename.txt with the file name and extension you like. Other common extensions include ".docx" (Word document), ".png" (empty image file), ".xlsx" (Excel document), and ".rtf" (for text has basic format).

Press ↵ Enter.

Create text files. If you don't want to create a text file, go to the next step. Use the following steps to create a raw text file into which you can import content:

Type , but replace testfile with the filename you prefer.copy con testfile.txt

Press ↵ Enter.

Enter content as you like. This is a rudimentary text editor, but still effective for writing code or taking quick notes. You can use the key Enterwhile editing to enter text on the next line if you like.

Press Ctrl+ Zwhen you finish editing the file. This operation saves all imported content to the file.

Another way to do this enter the .echo nhập nội dung tại đây > tên tập tin.txt

Create a file of a certain size. If you don't want to resize the file, skip this step. To create an empty file by 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 needed for the file.

Delete files

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

Open Command Prompt in two quick ways:

Right-click the Start menu and select Command Prompt .

Press ⊞ Win+ Sto open the search bar, type cmdthen click Command Prompt in the search results.

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

Access 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 want to use another folder, you will enter and press . Replace path_to_folder with the folder's path.cd path_to_folder ↵ Enter

For example, if you want to create a file on the Desktop, enter cd desktopand 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:UsersTênDesktopFiles).

Enter dirand press ↵ Enterto open a list of all files in the current folder. 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.

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

Enter and press .del filename↵ Enter Replace filename with the full name and extension of the file you want to delete. The file name includes the file extension (such as *.txt, *.jpg). This will delete the file from your computer.

For example, to delete a text file named "hello", you would enter del hello.txtCommand Prompt.

If the filename contains spaces (e.g., "hi there"), you would enclose the filename in quotes (e.g., del "hi there").

If you receive a message that the file cannot be deleted, use the command , as this command is used to delete read-only files.del /f filename instead

4.5 ★ | 2 Vote

May be interested

  • How to Change Directory in Command PromptHow to Change Directory in Command Prompt
    this article shows you how to change folders in the command prompt program on a windows computer. to change commands in command prompt, you must use an administrator account.
  • How to HIDE / SHOW files and folders by cmd command on Win 10/8/7How to HIDE / SHOW files and folders by cmd command on Win 10/8/7
    instructions on how to hide / show files or folders by command in command prompt. the trick to hide files with the cmd command on windows operating systems is extremely fast
  • How to Delete a File Using Command PromptHow to Delete a File Using Command Prompt
    this wikihow teaches you how to delete a file from your pc's desktop by using a command in command prompt. locate your file. if you know where the file is, you can navigate to it by simply opening the appropriate folder. for example, if...
  • How to create multiple folders at the same time on Windows 10How to create multiple folders at the same time on Windows 10
    creating multiple folders manually such as right-clicking to select new folder or using ctrl + shift + n is very time consuming.
  • How to Create a Custom Windows Command PromptHow to Create a Custom Windows Command Prompt
    the windows command prompt (located at c:windowssystem32cmd.exe) is a useful tool to perform various administrative tasks. the prompt is a string of characters (special and non special) that are displayed whenever the command prompt is...
  • 3 ways to create multiple folders at once in Windows 10/113 ways to create multiple folders at once in Windows 10/11
    the latest versions of windows allow you to automate quite a few of your tasks, such as allowing you to create multiple folders and subfolders at once.
  • How to Launch Python Files Using Windows Command PromptHow to Launch Python Files Using Windows Command Prompt
    today's tipsmake will show you how to open python files using the built-in command prompt program on windows computers. in most cases, you will open the file without any problems as long as python is available on your device. if your computer uses an old version of python, or you customized it when installing and did not add the 'python' command to the 'path' variable list, proceed to add python to the 'path' variable list to be able to start. run python files through command prompt.
  • How to Add and Delete Users Accounts With Command Prompt in WindowsHow to Add and Delete Users Accounts With Command Prompt in Windows
    command prompt, which is essentially windows' version of apple's 'terminal' app, allows you to enter system-altering commands. while most user commands one might enter in command prompt are easier to carry out by simply performing the...
  • How to open Command Prompt on Windows 10, 8, 7, Vista and XPHow to open Command Prompt on Windows 10, 8, 7, Vista and XP
    command prompt is one of the command line interface programs used to execute commands in the windows operating system. the article will guide you how to open command prompt on windows 10, 8, 7, vista and xp.
  • Add Command Prompt to Power User Menu on Windows 10Add Command Prompt to Power User Menu on Windows 10
    on windows 10 build 14971, microsoft replaced command prompt and command prompt (admin) with windows powershell. according to microsoft, this change will bring the best command line experience to users. but in fact, users prefer to use command prompt rather than using powershell.