Skip to content

Instantly share code, notes, and snippets.

View Mike-Dellisanti-Bose's full-sized avatar

Mike D Mike-Dellisanti-Bose

View GitHub Profile
@89465127
89465127 / argparse_files.py
Last active August 27, 2022 14:24
Get a list of filenames using argparse (updated to use default formatter)
import argparse
import os
import glob
def main():
#Does not currently have support to read files from folders recursively
parser = argparse.ArgumentParser(description='Read in a file or set of files, and return the result.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('path', nargs='+', help='Path of a file or a folder of files.')
parser.add_argument('-e', '--extension', default='', help='File extension to filter by.')
args = parser.parse_args()