I can list certain files but my code has problems that it only can list files in C:\
I want to change the code so I can scan other drives (for example: drive D, E, F & ...)
How can i do this
Please check my code first and then respond to my question to know what I mean
My code:
import os
def discoverFiles(start):
extensions = [
'pdf','mp3','mp4','txt','docx'
]
for dirpath, dirs, files in os.walk(start):
for i in files:
absolute_path = os.path.abspath(os.path.join(dirpath, i))
ext = absolute_path.split('.')[-1]
if ext in extensions:
yield absolute_path
x = discoverFiles('/')
for j in x:
print (j)