Aug-14-2020, 11:48 AM
I think you just need to rethink your logic in the for loop at line 10 and your error condition/message in lines 12-14. You are currently looping through all of the contents of the file path and printing the error each time an item doesn't have one of your chosen extensions. You are guaranteed to encounter the error at least once per execution, because the Thumbnails folder is going to be one of the items in the path, and that will trigger the message since it doesn't have an extension. It would probably make more sense to print the error only if there are no valid image files to work with, but otherwise just ignore any non-image files as long as there is at least one valid image in the path.
There are lots of ways to approach this, but one thing that might make it easier is to first create a list of items in the path, then work with the list:
There are lots of ways to approach this, but one thing that might make it easier is to first create a list of items in the path, then work with the list:
file_list = [f for f in os.listdir(path)] # put a check here to confirm that at least one valid image is present in file_list, otherwise print error and start over # after confirming there is at least one valid image, remove non-images from file_list # loop through file_list, which now contains only valid images in the path, to perform image manipulations