How To: Delete a Folder Using Command Prompt



Updated December 2024: Stop getting error messages and slow down your system with our optimization tool. Get it now at this link
  1. Download and install the repair tool here.
  2. Let it scan your computer.
  3. The tool will then repair your computer.

Sometimes it can take forever to delete a folder and its contents in Windows Explorer, especially when it is a large folder, because each file is deleted individually. The fastest way is to delete the folder from the Windows command prompt.

The command prompt is one of the most fundamental elements of Windows. If all else fails, the Command Prompt will eventually help you. One of those things where the command prompt could be your ultimate hope is if your computer is infected, and once you have cleaned it, no matter how long you try, many files and folders remain that would simply refuse to be deleted.

In such a situation, it becomes extremely important to delete these files, as there is a risk that the infection will recur. How to delete files on Windows that cannot be deleted with Windows Explorer?

December 2024 Update:

You can now prevent PC problems by using this tool, such as protecting you against file loss and malware. Additionally, it is a great way to optimize your computer for maximum performance. The program fixes common errors that might occur on Windows systems with ease - no need for hours of troubleshooting when you have the perfect solution at your fingertips:

  • Step 1 : Download PC Repair & Optimizer Tool (Windows 10, 8, 7, XP, Vista – Microsoft Gold Certified).
  • Step 2 : Click “Start Scan” to find Windows registry issues that could be causing PC problems.
  • Step 3 : Click “Repair All” to fix all issues.

Download Now

Well, you can use a free tool for Windows called Unlocker and it will help you delete all non-erasable files and folders from Windows with ease.

Forcing deletion in Windows

First, open the command prompt. To do this, first open the Start menu (Windows key), type run, then press Enter. In the dialog box that appears, type cmd, then press Enter again.

When the prompt opens, type del /f filename, where filename is the name of the file or files (you can specify multiple files with commas) that you want to delete.

Orders may require an explanation.

DEL /F/Q/S *.* > NIL

/F — forces the deletion of read-only files.
/Q — activates the standby mode. You will not be asked if it is possible to delete files (if you do not use them, you will be asked for a file in the folder).
/S — — — executes the command on all files in any folder under the selected structure.
*.* * — delete all files.
> NULL — Disables the console output. This further improves the process and reduces the processing time of the console control by about a quarter.

RMDIR /Q/S folder name

/Q — Standby mode, does not ask for confirmation to delete folders.
/S — Performs the operation in all folders of the selected path.
Folder name — The absolute path or relative folder name, for example o:/backup/test1 or test1.

Note that to delete the file, you must either specify the full path of the file where you replace the file name, or navigate to the folder where it is located using cd folderpath, and then execute the del command. See the image below for an example of the latter method.

To delete a non-empty folder

 

The simple rmdir does not work for folders with a certain content.

C:>rmdir nonemptydir nonemptydir nonemptydir nonemptydir
The directory is not empty.

Use the /s option to delete the contents of the folder with the folder. This will delete all subfolders recursively.

C:>rmdir /S nonemptydir non vide
nonemptydir, are you sure (Y/N)? y
C:>

CONCLUSION

All files and folders on the computer can be deleted at the command prompt. And all versions of Windows have a command prompt that allows users to execute certain commands to perform a particular function.

https://superuser.com/questions/537757/completely-delete-a-folder-in-windows-using-command-line/537760



Expert Tip: This repair tool scans the repositories and replaces corrupt or missing files if none of these methods have worked. It works well in most cases where the problem is due to system corruption. This tool will also optimize your system to maximize performance. It can be downloaded by Clicking Here

Scroll to Top