How to Clear the Recycle Bin Using Python?

Estimated read time 1 min read

To clear the Recycle Bin using Python, you can use the send2trash module, which provides a cross-platform way to send files and folders to the trash or Recycle Bin.

Here’s an example that uses send2trash to clear the Recycle Bin on Windows:

import send2trash
import os

if == 'nt':  # check if running on Windows

Note that the $Recycle.Bin folder is the top-level folder of the Recycle Bin on Windows, and deleting it will delete all items in the Recycle Bin. Be sure to use this with caution and only if you are certain you want to permanently delete all files and folders in the Recycle Bin.

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply