Removing hidden files and folders with python ...
gagsl-py2 at yahoo.com.ar
Wed Jan 30 14:24:14 CET 2008
On 30 ene, 06:21, Konrad Mühler <kon... at isg.cs.uni-magdeburg.de>
> I try to delete a whole directory-tree using shutil.rmtree(...)
> But there are always the hidden files and folders (e.g. from the svn
> .svn) left.
> How can I delete -all- files and folders (also the hidden) with python?
I assume you use Windows.
You have to reset the "readonly", "system" and "hidden" directory
attributes. os.chmod can reset the first one, but for the others you
have to use ctypes or the pywin32 package to call the
Of course there is system too:
os.system("attrib -r -h -s filename")
You could use rmtree once, apply the above on the remaining files and
directories -if any- and try rmtree again.
More information about the Python-list