Skip to content

Instantly share code, notes, and snippets.

@holmanb
Created November 30, 2023 20:46
Show Gist options
  • Save holmanb/5537596264de068a0745ddb8850c5883 to your computer and use it in GitHub Desktop.
Save holmanb/5537596264de068a0745ddb8850c5883 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
import os
from pathlib import Path
help = """\
iterate a directory of directories, printing
the files in the sub-directory as alphabetical csv
python3 iter_dir.py /some/path
"""
if len(sys.argv) == 1 or "help" == sys.argv[1]:
print(help)
os._exit(0)
for file in Path(sys.argv[1]).iterdir():
if file.is_dir():
print(",".join([str(f) for f in Path(file).iterdir()]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment