# show file list on the dir import os file_list = os.listdir() for file in file_list: if file.endswith(".png"): file_size = os.path.getsize(file) print(file + ":{}".format(file_size)) if file_size < 300000: os.remove(file)