I am trying to create a python script that can receive multiple files as input through a command line.
Right now I am working with a method of using one file as input:
I would presently call the function using: python function_name.py input_file.txt
Using code that looks like this:
import sys
def function_name():
input = sys.argv[1]
with open(input,'r') as afile:
read_data = afile.read()
if __name__ == '__main__':
function_name()
But how can I use all of the .txt files in the current directory as input?
i.e.: python function_name.py *.txt
OR: python function_name.py ./*/*.txt
I would like to perform the same actions on each input file.