How to delete files and folders with CMD on Windows 10/11 – LLODO


If you prefer to use the command line, Windows 10/11 provides several commands to help you delete files and folders using Command Prompt. I will show you how to do this.

How to delete files and folders using Command Prompt on Windows 10

How to delete files with CMD on Windows 10/11

If you have enjoyed researching about CMD, you should not ignore 27 interesting CMD tips on Windows that I wrote.

To delete Files with Command Prompt on Windows 10, you can use the built-in del command. This command helps you to delete specified Files from your PC.a

Warning: The del command will delete the specified File without moving it to the Trash. This means that you cannot retrieve your File after it has been deleted.

To use the command, first open the Command Prompt. Do this by opening the Start Menu, searching for “Command Prompt” and clicking “Run as Administrator” to the right of the search results.

How to delete files and folders with CMD on Windows 10/11

In the “User Account Control” window, click “Yes”.

You now have a Command Prompt window open. Here, enter the following command, replacing PATH with the full path to the File you want to delete. Then press Enter.

del PATH

For example, to delete a File named “MyFile.txt” on the Desktop, use the following command to replace username with your own username:

del "C:UsersusernameDesktopMyFile.txt"

How to delete files and folders with CMD on Windows 10/11

And the specified File has been deleted from your memory!

To customize the deletion process, you can use a few parameters that the del command provides.

For example, you can add the /p parameter to the command so that the Command Prompt confirms your request before deleting the File. Similarly, you can add the /f parameter to the command to force delete your read-only files.

Here is the command with the /p parameter:

del /p "C:UsersusernameDesktopMyFile.txt"

How to delete files and folders with CMD on Windows 10/11 39

Delete folder with CMD on Windows 10

To delete folders on your PC, use the built-in rmdir command in Windows. This command helps you to delete folders as well as subfolders and files within them.

Warning: The rmdir command deletes directories without moving them to the Recycle Bin. You cannot restore your folders once they have been deleted with this command.

To use this command, open a Command Prompt window. Do this by opening the Start Menu, finding “Command Prompt” and clicking “Run as Administrator” to the right of the search results.

How to delete files and folders with CMD on Windows 10/11 40

In the Command Prompt window, enter the following command replacing PATH with the full path to the directory you want to delete. Then press Enter.

Note: Make sure that the folder you are deleting does not contain any Files or folders. If the folder is not empty, use the second command given below to delete your folder.

rmdir PATH

For example, to delete a folder named “MyFolder” on the Desktop, use the following command to replace username with your own username:

rmdir "C:UsersusernameDesktopMyFolder"

How to delete files and folders with CMD on Windows 10/11 41

And the command will delete the specified folder from your PC!

If the directory you want to delete contains any Files or directories in it, add the /s parameter to the command and this will delete all subdirectories and Files inside that directory.

rmdir /s "C:UsersusernameDesktopMyFolder"

How to delete files and folders with CMD on Windows 10/11 42

Different uses of the Del . command

With the del command, you can use your creativity to delete files in a variety of ways. For example, you can delete certain types of files, delete only files with a certain word in their name, etc.

For example, to delete all PNG files in your current directory in Command Prompt, you can use the following command:

Tip: Replace “.png” with whatever File extension you want to remove.

del *.png

How to delete files and folders with CMD on Windows 10/11 43

This command selects all PNG files in the current directory and deletes them.

Another creative use of the del command is to delete files that contain a certain word in their name. For example, to delete all files whose name starts with “word”, you would use the following command:

Tip: Add an asterisk before the word to remove all Files ending with your specified word.

del "word*"

How to delete files and folders with CMD on Windows 10/11 44

Finally, if you want to delete all files from the current directory, use the following command:

del *.*

How to delete files and folders with CMD on Windows 10/11 45

And that’s how you delete files and folders using CMD. Very handy!

Deleting files using these methods is certainly not as intuitive as using graphical software, but you can still use this method like cmd.

In addition, you can also use CMD to increase internet speed here.



Link Hoc va de thi 2021

Chuyển đến thanh công cụ