Basic List Files Script
Created this simple script to help determine how many images of a single file type had been output to a specific Directory. The script gives you a count of files and also outputs a text file to tell you all files that it found for the specific file type.
#### Script Written by JesusM #### #### Script Built running Python310 #### #### Script Build Date: 20240111 #### #### Script Functionality: List Files in a Directory based on Type #### import os FOLDER_DIR = r"E:\Users\jmundo\Pictures" IMAGE_TYPE = ".jpg" def main(): error_log = [] fileCount = 0 with open(r"FileList.txt", "w") as a: for path, subdirs, files in os.walk(FOLDER_DIR): if os.path.isdir(FOLDER_DIR): output_list = [] for filename in files: if filename.endswith(IMAGE_TYPE): output_name = filename[:-4] output_list.append(output_name) fileCount += 1 print(output_name) with open(r"FileList.txt", "a+") as myfile: for line in output_list: myfile.write(line + '\n') print("Output Names Processed: " + str(fileCount)) if __name__ == '__main__': main()