Empty the Trash via Command Prompt

Stefan
Empty the Trash via Command Prompt

We all know how to empty the trash through it trash bin icon on the desktop. However, there is also an alternative way to empty the trash, namely via the Command Prompt.

For example, you can automate this. If you use scripts, you could automate the command to empty the trash by processing it in a script. Even if you only have access to a Command Prompt, you can use this command to empty the trash.

Another reason is if Windows stops functioning properly or if Explorer freezes when you try to empty the trash. In this guide I explain how it works.

Empty the Trash via Command Prompt

The recycle bin as we know it is, so to speak, just a folder on your computer. This folder contains files and subfolders and emptying the trash will empty this folder. This is a hidden folder called “$Recycle.Bin”. This folder is located on every disk. That means if you have multiple drives you will need to change the drive letter in the command below to empty the trash on that drive.

This command permanently deletes all files in the specified folder. It is important to be sure that you really want to delete all files in the Recycle Bin.

To begin open a Command Prompt as administrator. Then enter the following command:

rd /s /q c:\$recycle.bin\

As indicated, you change c: to another drive to empty the trash there if you have another or more drives. Here is an explanation of what this command does.

Read also
Icons not working in Windows 11? Try these tips!

Empty the Trash via Command Prompt

  1. rd: This stands for 'remove directory'. It is a command used to delete a folder and all files and subfolders within it.
  2. /s: This option stands for 'subdirectories'. It ensures that in addition to the folder itself, all subfolders and files within that folder are also deleted. Without this option, the 'rd' command would only be able to delete empty directories.
  3. /q: This stands for 'quiet mode'. Normally the 'rd' command asks for confirmation before deleting files and folders. The /q option suppresses these confirmation prompts so that deletion occurs automatically without interaction.
  4. C:$Recycle.Bin: This refers to the location of the Recycle Bin on the C: drive. $Recycle.Bin is a system folder that contains the deleted files. The $ indicates that it is a hidden system folder.

Use this command with caution and make sure you understand what it does before executing it. It is also advisable to make backups of important data before executing the above command.

Also read: Automatically delete files in Recycle Bin.

I hope this helped you. Thank you for reading!


Problem solved?


Help other people too.
Share this article on a website, forum or via social media.

Join our new computer forum for questions and computer help.
Do you have a computer question?

The email address will not be published. Required fields are marked with *