Steven you are right, isDirEmpty() isn't even used. That's what
happens when you try to get a last minute thread going 5 minutes
before home time! ;-)
Thanx for the responses guys! It's been very useful :)
On 30 Mar, 16:38, Steven D'Aprano wrote:
> On Mon, 30 Mar 2009 08:14:55 -0700, Cinnam
On Mon, 30 Mar 2009 08:14:55 -0700, CinnamonDonkey wrote:
> My understanding was that rmtree removes a whole tree not just the empty
> directories?
So it seems:
>>> os.mkdir('die-die-die')
>>> os.mkdir('die-die-die/stuff')
>>> shutil.rmtree('die-die-die')
>>>
Revised:
root
+ Dir1
+ Dir2
+ Dir3
+ NotEmptyDir
File1
File2
Result:
Root
+ NotEmptyDir
File1
File2
---
import os
import shutil
def isDirEmpty( path ):
if not os.path.isdir( path ):
return False
contents = os.listdir( path )
i
My understanding was that rmtree removes a whole tree not just the
empty directories?
eg.
root
- file1
- file2
- dir1
- dir2
- file3
- dir3
I would expect; dir1 and dir3 to be deleted and nothing else touched.
My attempt came up with:
import os
import shutil
def isDirEmpty( path ):
CinnamonDonkey wrote:
> Hi All,
>
> I've been scratching my head all afternoon trying to work out the best/
> quickest way is to delete empty directories within a tree (Windows).
>
> I've looked at os.walk() but it seems to traverse the directory tree
> in the wrong order (is it possible to reverse
CinnamonDonkey wrote:
Hi All,
I've been scratching my head all afternoon trying to work out the best/
quickest way is to delete empty directories within a tree (Windows).
I've looked at os.walk() but it seems to traverse the directory tree
in the wrong order (is it possible to reverse the order
Hi All,
I've been scratching my head all afternoon trying to work out the best/
quickest way is to delete empty directories within a tree (Windows).
I've looked at os.walk() but it seems to traverse the directory tree
in the wrong order (is it possible to reverse the order?)
It seems the only wa