Vote count:
0
I’m new to programming and could do with a little help. I’m trying to make a program that will search for files in a specified directory by extension (multiple extensions) and then only return specific results which have my list of keywords in the filename. I have the following:
import os from fnmatch import fnmatch
root = 'c:\users' pattern = "*.css"
for path, subdirs, files in os.walk(root): for name in files: if fnmatch(name, pattern): print os.path.join(name)
This will bring back all files with a single extension, in this case .css files, but I need it to do more such as image and text file extensions. I would also like it to only return files that have specific keywords in the file name. Can anyone point me in the right direction?? Thanks
Aucun commentaire:
Enregistrer un commentaire