Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import os
import sys
def usage():
print("Usage: readfolder.py [folder]")
def doread(dir):
for root, dirs, files in os.walk(dir):
for file in files:
fpath = os.path.join(root, file)
with open(fpath, "rb") as f:
f.read(os.path.getsize(fpath))
print("Read {}".format(fpath))
def main():
if len(sys.argv) != 2:
usage()
sys.exit(-1)
print("About to read all files in {}...".format(sys.argv[1]))
doread(sys.argv[1])
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment