determine directories with wildcard
Simon Brunning
simon.brunning at gmail.com
Tue Mar 8 08:54:26 EST 2005
On Tue, 8 Mar 2005 14:33:59 +0100, Thomas Rademacher
<rademacher at prostep.fta-berlin.de> 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 about something like:
import fnmatch
import os
root = 'd:\\'
filter = r'*\*python*\*'
for dirpath, dirnames, filenames in os.walk(root):
if fnmatch.fnmatch(dirpath, filter):
print 'matched', dirpath
--
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/
More information about the Python-list
mailing list