I\'m trying to generate a text file that has a list of all files in the current directory and all of its sub-directories with the extension \".asp\"
. What would be
walk the tree with os.walk and filter content with glob:
import os
import glob
asps = []
for root, dirs, files in os.walk('/path/to/dir'):
asps += glob.glob(os.path.join(root, '*.asp'))
or with fnmatch.filter:
import fnmatch
for root, dirs, files in os.walk('/path/to/dir'):
asps += fnmatch.filter(files, '*.asp')