[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Removing hidden files and folders with python ...

Konrad Mühler

1/30/2008 8:21:00 AM

Hi,

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?

Many Thanks
Konrad
1 Answer

Gabriel Genellina

1/30/2008 1:24:00 PM

0

On 30 ene, 06:21, Konrad Mühler <kon...@isg.cs.uni-magdeburg.de>
wrote:

> 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
SetFileAttributes function.
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.

--
Gabriel Genellina