Delete Files with Command Prompt and Command Line

Photo of author

By Jason

The Windows computer’s command prompt and command line can be regarded as a good helper and a harmful tool.

The “rm” command can help us remove the data files from the computer, and the “rmdir” command can help us erase the directories and folders.

But the difference between deleting data with the command line and with the trash bin is that: it is hard for us to get the deleted things back.

So, it is noticeable that we use the command prompt and command line with great caution.

Advantages of Deleting Files by Command Prompt and Command Line:

It is easy and simple to use the trash bin when we want to delete something. So why do people use the command prompt and command line? The command prompt and command line can be used with ease. Let’s see the main advantages of the command prompt and command line:

  • 1. With the help of wildcards, we can remove the data files and folders effectively.
  • 2. The data files in the trash bin can be recoverable.
  • 3. All the data files, including the hidden ones, can be seen, and you can delete them too.
  • 4. The command prompt and command line can help you control the tools on your computer, even if the operating system goes wrong.

Besides, you will learn more about how to empty the Recycle Bin.

How to Delete Files and Folders on the Windows Computer by Using Command Prompt

Have you ever deleted any file or folder with the command prompt and command line? Do you know how to use this tool on a Windows computer? Let me walk you through this tutorial below:

Step 1. Launch the Command Prompt Tool

Click on the “Start” menu on the toolbar of the desktop, and then go to “All Programs” > “Accessories” > “Command Prompt.” And there is another way to fulfill this goal by the “run dialog.”

In the input blank of the “run dialog,” input “cmd” and then click on “OK.” Remember to omit the quotes, and please do so in the following passages.

Step 2. Type the Command Lines

First, input “del.” Then type the name of the file and the extension. If you have no idea about the extension, just go to the file on your Windows and see what is on the search bar.

If you are already in the directory of the file you want to delete, just go forward.

If you are not in the directory, you can just input the word “cd” to complete the path of the file you want to delete.

For example, if you want to delete a text file named “file.txt,” which is on the desktop, you can input something like this “C: /Users/username/Desktop\file.txt“.

Step 3. Use the Asterisk

The DEL command supports the wildcards, including the asterisk (*). For example, if you want to delete all the “WAV” files on your desktop, you can input the command line like this: “del C:\Users/username/Desktop/*.wav.

Step 4. Confirm the Deleting Process

After inputting what you want to delete, you can press the “ENTER” key on your keyboard to start deleting.

How to Delete Files and Folders on the Mac Computer by Using the Command Line

Since you have seen how to delete the files on the Windows computer, it can be referred to if you want to delete some files on your Mac computer.

Also, here you will find out how to fix the directory name is invalid issue.

How to Delete the Directory with the Rmdir Command

It is impossible to delete the directory with the rm command, just like the one I showed you above. But to fulfill this goal, you can use the rmdir command, which is a special command for deleting the directory.

It is noticeable that if you delete the directory, the files in it will also be deleted with your operation. And this may cost you a long time.

How to Delete the Directory

If you want to delete the directory, you can refer to the guidance below:

  • 1. Open the Archives tool. The tool you use to delete the directory is called the Archives.
  • 2. Remember, if you delete the directory with this method, you will have no way to recover it again. So you must confirm that all the data files in this directory are unwanted.

How to Use the rm-R Command

The rm – R command is also useful if the trash bin in your Mac computer can’t be emptied. That is to say, the files in the trash bin are not permitted to be deleted. But luckily, there is another useful. Just read on, please.

  • 1. Open the rm-R tool on your computer.
  • 2. Type a space.
  • 3. Go to the trash bin on your computer and then drag the files you want to delete to the Terminal Window. And then, you can see the command line like this: “/Users/.Trash/file.txt.“.
  • 4. After you confirm all the information on the Terminal Window, you can press the “ENTER” button to delete the files in the trash bin.

How to Open the Command Prompt from a Folder

Do you know there is also a way to open the command prompt from a folder, which is a time-saving method? What you need to do is to locate the folder you want and then right-click on the folder.

From the pop-up menu, choose the “open command window here” item. And right after that, the command prompt will show up.

How to See the Command History

You can refer to this tutorial when you want access to the command lines you inputted before.

You don’t have to input them all over again. Instead, you can use the “doskey /history” command line.

PS: Here, you can fix the AMD Quick Stream issue.

By the way, even if you lost files on your PC, there is still a chance to recover them. Here is the Best File Recovery Tool – Recoverit for you to get it back.

  • Recover deleted or lost photos, files, music, emails, and videos from your computer or other storage safely, effectively, and completely.
  • Support file recovery from recycle bin, hard drive, memory card, flash drive, digital camera, and camcorders.
  • You can retrieve files for formatting, sudden deletion, hard drive corruption, system crash, and virus attack under various situations.
  • You are allowed to preview and make a selective data recovery.
  • Well support for Windows Vista/XP/11/10/8/7, macOS 13 included

Get Recoverit

Leave a Comment