Re: Deleteing empty directories

2009-03-31 Thread CinnamonDonkey
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

Re: Deleteing empty directories

2009-03-30 Thread Steven D'Aprano
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') >>>

Re: Deleteing empty directories

2009-03-30 Thread CinnamonDonkey
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

Re: Deleteing empty directories

2009-03-30 Thread CinnamonDonkey
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 ):

Re: Deleteing empty directories

2009-03-30 Thread andrew cooke
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

Re: Deleteing empty directories

2009-03-30 Thread Tim Golden
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

Deleteing empty directories

2009-03-30 Thread CinnamonDonkey
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