Last active
July 30, 2019 17:06
-
-
Save ShannonScott/441601040f44b1e5d703dcf1ca34f957 to your computer and use it in GitHub Desktop.
[Python Walk File Tree] Walk a file tree in python. #python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
basepath = '/path/to/files' | |
extensions = ('.mp4', '.avi', '.mkv', '.mov') | |
for (dirpath, dirnames, filenames) in os.walk(basepath): | |
for filename in filenames: | |
basename, ext = os.path.splitext(filename) | |
if ext not in extensions: | |
continue | |
filepath = os.path.join(dirpath, filename) | |
print(filepath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment