Move files/directories to Recycle Bin using standard Python libs

kyosohma at kyosohma at
Wed Aug 15 21:56:48 CEST 2007

On Aug 15, 2:02 pm, "Chris Mellon" <arka... at> wrote:
> On 8/15/07, Kevin D.Smith <Kevin.Sm... at> wrote:
> > I would like to move files and directories to the Recycle Bin on
> > Windows from Python.  I have found some older articles describing how
> > to do this, but they require additional packages to be installed.  I'm
> > working on a plugin for an existing project and only have the standard
> > library to work with.  Is there a way to use the Recycle Bin using
> > standard Python?
> > --
> > Kevin D. Smith
> Not easily. The recycle bin is part of the shell, and the shell api
> calls have very complicated struct parameters that are cumbersome to
> use correctly from ctypes. If you do the work to map the fileop
> structs to ctypes you can call the shell API file operation functions
> in shell32.dll. This assumes that "standard" for you is Python 2.5,
> which has ctypes. Otherwise you are out of luck.

Technically, you can download ctypes for 2.3/2.4 as well or compile it
for whatever version you want, I think. See here:

Besides, you can bypass ctypes and use SHFileOperation to do it, as is
shown here:


More information about the Python-list mailing list