i need to ask if possible and how get on same time the sum of list files in directory and subdirectory with fnmatch filter and files adress.
I use for now this:
def return_ext():
file_pasok = ["AAAAA.txt", "BBBBBB.txt"]
for i in range(len(file_pasok)):
for ext_f in file_pasok:
return ext_f
def list_files(file_path):
ext = return_ext()
for _, dirnames, filenames in os.walk(file_path):
if not filenames:
continue
for file in fnmatch.filter(filenames, ext):
file_found_str = Path(os.path.join(_, file))
file_found = str(file_found_str)
yield file_found
ext = return_ext()
########GOT HOW MANY FILE FOUND
count_founded = sum([len(fnmatch.filter(files, ext)) for r, d, files in os.walk(file_path)])
########GOT LIST ADRESS FILE FOUND
for file_found in list_files(file_path):
print(file_founds)
But of course the script make 2 time the same search :( Thanks so much for any suggest !!