Created
January 10, 2019 01:51
-
-
Save liushapku/a79ba06fab6c843c02ab382585591882 to your computer and use it in GitHub Desktop.
python scan tree
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 os | |
def scantree(*paths): | |
for path in paths: | |
if os.path.exists(path): | |
for entry in sorted(os.scandir(path), key=lambda x: x.name.lower()): | |
yield entry | |
if entry.is_dir(follow_symlinks=False): | |
yield from scantree(entry.path) | |
else: | |
yield entry | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment