Skip to content

Instantly share code, notes, and snippets.

@j1o1h1n
Created March 29, 2023 01:01
Show Gist options
  • Save j1o1h1n/fb582bccbc2ba5626960f9efeaa2baf4 to your computer and use it in GitHub Desktop.
Save j1o1h1n/fb582bccbc2ba5626960f9efeaa2baf4 to your computer and use it in GitHub Desktop.
visit files using os.walk and pathlib
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