Create test_get_files.py
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
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)
|
||||||
Reference in New Issue
Block a user