Files
datenbanken-llm/test_get_files.py
T
2024-12-10 19:10:07 +01:00

24 lines
529 B
Python

import os
def read_files(path, output, filetypes=None):
print(os.path.join(path))
if filetypes is None:
filetypes = ["pdf", "txt", "png", "jpg", "mp3"]
for root, dirs, files in os.walk(path):
for file in files:
if (type := file.split(".")[-1]) in filetypes:
output.append((type, os.path.join(path, file)))
for dir in dirs:
read_files(os.path.join(path, dir), output)
break
output = []
read_files("C:\\SoftwareEng", output)
print(output)