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
\".asp\"
You'll want to use os.walk which will make that trivial.
import os asps = [] for root, dirs, files in os.walk(r'C:\web'): for file in files: if file.endswith('.asp'): asps.append(file)