Deleteing empty directories

andrew cooke andrew at acooke.org
Mon Mar 30 17:22:09 CEST 2009


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?)

the documentation for os.walk() explains how to reverse the order.

http://docs.python.org/3.0/library/os.html#os.walk

andrew


>
> It seems the only way is to manually walk the tree myself recursively
> and then back up deleteing a directory if it is found to be empty.
>
> Any ideas?
>
> Cheers,
> SHaun >8)
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>





More information about the Python-list mailing list