I have the following function currently:
def create_image_list(directory):
extensions = ('.jpg', 'jpeg', '.png', '.bmp')
file_list = []
for root, directories, files in os.walk(directory):
for filename in files:
if filename.endswith(extensions):
filepath = os.path.join(root, filename)
file_list.append(filepath)
Which goes through every file and subdirectory in a given directory and puts the full path to any files with the given extensions in the list. However, I would like to ignore certain subdirectories, such as those labelled thumbs
. How would I go about this?