import os ch = os.chdir("Directory") #for example: E:/../../ files = os.listdir() for file in files: if "file name .format" in file: os.remove(file) #code by fawlid