5

I'm trying to delete files that are in the recycle bin by using python, but i can't find a way to do it. Thanks.

Shir K.
  • 113
  • 1
  • 4
  • 3
    What OS? Please do not assume everyone know your environments. Also please read [How to ask](http://stackoverflow.com/help/how-to-ask) – wizzup Feb 07 '17 at 12:07
  • @wizzup You are referring to a question asking for file deletion, not emptying a recycle bin. – gus27 Feb 07 '17 at 12:34

2 Answers2

15

For the Windows OS you can use the winshell module and it's empty method.

Emptying the recycle bin is as easy as:

import winshell
winshell.recycle_bin().empty(confirm=False, show_progress=False, sound=False)

See some examples here.

gus27
  • 2,616
  • 1
  • 21
  • 25
0

There's a Windows shell module wrapped by PyWin32 that does this, assuming the question is for Windows.

http://timgolden.me.uk/pywin32-docs/shell__SHEmptyRecycleBin_meth.html

Simon Hibbs
  • 5,941
  • 5
  • 26
  • 32