I have a directory of .jpg files I need to loop through, and it has to be invoked from the command line with python program.py directory/*.jpg
The code I have only finds the first image in that folder.
import sys, glob
arg = sys.argv[1]
files = glob.glob(arg)
for fname in files:
print(fname)
It only prints out the name of the first file in the folder, when I print the length of the list files, it returns 1.
Edit: print(arg) is printing the name of the first file, rather than the directory, how do I fix this, sys.argv[1] should be the directory/*.jpg no?