Created
February 21, 2022 13:30
-
-
Save nimpy/92725af4c81e0c2ae1da09cf0b1b7d17 to your computer and use it in GitHub Desktop.
Print the names of all sub-directories for the current directory in reversely sorted alphabetical order
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
# credit: https://stackoverflow.com/a/44228436/4031135 | |
from pathlib import Path | |
p = Path('.') | |
# all subdirectories in the current directory, not recursive | |
list_subdirs = [f.name for f in p.iterdir() if f.is_dir()] | |
list_subdirs = sorted(list_subdirs, reverse=True) | |
for subdir in list_subdirs: | |
print(subdir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment