Move files/directories to Recycle Bin using standard Python libs

Chris Mellon arkanes at gmail.com
Wed Aug 15 15:02:24 EDT 2007


On 8/15/07, Kevin D.Smith <Kevin.Smith at sas.com> 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.



More information about the Python-list mailing list