import os dir_name = "folder_path" files = os.listdir(dir_name) for file in files: if file.endswith(".png"): os.remove(os.path.join(dir_name, file))