Per your question on how to run this on multiple file extensions, the simplest solution is just to call the locate function multiple times. Such as:
for ext in ('*.txt', '*.thn', '*.csv'):
# This will run three times first returning all
# the TXT files, then THN,and finally CSV files
filelist = locate(ext, r'D:\path')
for fp in filelist:
# Do what you need to with this file
# You can also use the variable 'ext' here to
# process files differently base upon the 'ext'