Hello
I want to put all files recursively in a directory into a list with only certain type of extensions.
Here is what I did.
Thanks
I want to put all files recursively in a directory into a list with only certain type of extensions.
Here is what I did.
#!/usr/bin/env python3
from glob import glob
EXTN = ('*.avi', '*.flv', '*.mkv', '*.mov', '*.mp4',
'*.mpeg', '*.mpg', '*.webm', '*.wmv')
video_files = []
for file in EXTN:
video_files.extend(glob("**/*" + file, recursive = True))
video_files.sort()I'm using Python 3.8.5. Is this the proper way? Or there any best method I can use to store all files with a particular type of extensions in a list?Thanks
