How to Empty Recycle Bin when it hangs due to lots of files?


Once, the Google Drive moves lots of deleted files into Recycle bin and I was trying to empty the recycle bin using the intuitive way, right click Recycle and click the Empty. But it takes a long time before it shows the following and hangs forever.

empty-recycle-bin How to Empty Recycle Bin when it hangs due to lots of files? bash script tricks windows windows batch

empty-recycle-bin hangs

The files in the Recycle bin are about 40GB and it seems the Windows OS is trying to figure out the size. The desktop may freeze during its process to finding out what those files to delete but it is not necessary. The solution to empty recycle bin correctly is to launch the command shell and run the command:

rd /s /q %systemdrive%\$Recycle.Bin

Normally, the %systemdrive% refers to C:\ but the files are spread out to different drive letters, so you would need to do a loop:

for %d in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @(
    @if exist %d:\$Recycle.Bin\NUL rd /s /q %d:\$Recycle.Bin
)

The /s of rd command removes subtrees of a folder and /q is the quiet model so it does not prompt for deletion. After a while, it silent returns to the DOS prompt and the recycle bin is emptied.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
335 words
Last Post: How to Count Numbers with Unique Digits?
Next Post: Can a Win32 C++ Process Kill Itself?

The Permanent URL is: How to Empty Recycle Bin when it hangs due to lots of files?

3 Comments

  1. Dave
  2. Kev

Leave a Reply