import os import re directory = "../chess-mamba-vs-xformer/out/Xformer/50M/" for filename in os.listdir(directory): if filename.endswith(".pt"): if filename == "ckpt.pt": continue match = re.search(r'ckpt_(\d+)(?:b|g)', filename) if match: number = int(match.group(1)) if number > 33219200: file_path = os.path.join(directory, filename) os.remove(file_path)