Skip to content

Instantly share code, notes, and snippets.

@isaidnocookies
Created February 15, 2021 21:13
Show Gist options
  • Save isaidnocookies/e120a989a0acbeae4bb50e55a9f21004 to your computer and use it in GitHub Desktop.
Save isaidnocookies/e120a989a0acbeae4bb50e55a9f21004 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/python3
import os, sys
from pathlib import Path
def parseDirectories(rootdir):
for subdir, dirs, files in os.walk(rootdir):
for file in files:
if ('.DS_Store' in file):
continue
filePath = os.path.join(subdir, file)
parentName = os.path.split(Path(filePath).parent)[-1]
print ('{} -> {}'.format(parentName, file))
with open(filePath, encoding="latin-1") as fileObj:
data = fileObj.read()
print ('{}\n'.format(data))
if __name__ == '__main__':
if len(sys.argv) < 2:
exit()
else:
parseDirectories(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment