using wild card when listing directories in python

Posted by user248237 on Stack Overflow See other posts from Stack Overflow or by user248237
Published on 2010-06-11T19:50:12Z Indexed on 2010/06/11 19:52 UTC
Read the original article Hit count: 187

how can I use wild cars like '*' when getting a list of files inside a directory in Python? for example, I want something like:

os.listdir('foo/*bar*/*.txt') 

which would return a list of all the files ending in .txt in directories that have bar in their name inside of the foo parent directory.

how can I do this?

thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about file-io