File size: 662 Bytes
7a0c684 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import os
import glob
def cleanup_bak_files():
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
bak_files = glob.glob(os.path.join(root_dir, '**/*.bak'), recursive=True)
if not bak_files:
print("No .bak files found.")
return
print(f"Found {len(bak_files)} .bak files:")
for bak_file in bak_files:
try:
os.remove(bak_file)
print(f"Deleted: {bak_file}")
except Exception as e:
print(f"Error deleting {bak_file}: {e}")
print("\nCleanup complete.")
if __name__ == "__main__":
cleanup_bak_files()
|