Quick File Clean Up For WebGUI Image Processing
import glob, os print ('Paste Your Folder Path: ') directory = input() os.chdir(directory) txtfilelist = [] pngfilelist = [] for txtfile in glob.glob("*.txt"): txtfilelist.append(txtfile.replace(".txt","")) for pngfile in glob.glob("*.png"): pngfilelist.append(pngfile.replace(".png","")) SetDiff = set(txtfilelist).difference(pngfilelist) for x in SetDiff: x = x + ".txt"; filepath = directory + "/" + x os.remove(filepath) print ('Files Cleaned Up')