Created
March 29, 2023 01:01
-
-
Save j1o1h1n/fb582bccbc2ba5626960f9efeaa2baf4 to your computer and use it in GitHub Desktop.
visit files using os.walk and pathlib
This file contains 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 pathlib | |
import os | |
def visitfiles(top, visit, topdown=True, onerror=None, followlinks=False): | |
for root, dirs, files in os.walk(top, topdown, onerror, followlinks): | |
for file in files: | |
p = pathlib.Path(root) / file | |
visit(p) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment