Remove all directories using wildcard
Rikishi42
skunkworks at rikishi42.net
Sat Mar 19 19:34:48 EDT 2011
On 2011-03-18, JSkinn3 <skinner_1377 at hotmail.com> wrote:
> I'm new to python and I am trying to figure out how to remove all sub
> directories from a parent directory using a wildcard. For example,
> remove all sub directory folders that contain the word "PEMA" from the
> parent directory "C:\Data".
>
> I've trying to use os.walk with glob, but I'm not sure if this is the
> right path to take.
I see you've got 2 suggestions allready.
Wichever you use, please note you need to begin the search from the bottom
of the tree. The call to os.walk should include a False value for the
direction of the walk:
os.walk("c:/data", False).
--
When in doubt, use brute force.
-- Ken Thompson
More information about the Python-list
mailing list