Thomas Rademacher wrote: > Hello, > > I want to collect with the wildcard '*' all existing directories. > For example: /dir/dir/*/dir/*/dir/* or C:\dir\dir\*\dir\*\dir\* > > How can I resolve this problem?
This is some sort of pattern matching. What I'd do is to convert your pattern to a regex: rex = re.compile(r"/dir/dir/.*/dir/.*/dir/.*") Then create a list of dirs with os.walk: dirs = [dirpath for dirpath, foo, bar in os.walk(topdir) if rex.match(dirpath)] This is untested, but should do the trick. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list