Skip to content

Instantly share code, notes, and snippets.

@kirugan
Created October 11, 2025 22:24
Show Gist options
  • Select an option

  • Save kirugan/fc3c539f56376d33f1816d85372f4172 to your computer and use it in GitHub Desktop.

Select an option

Save kirugan/fc3c539f56376d33f1816d85372f4172 to your computer and use it in GitHub Desktop.

Revisions

  1. kirugan created this gist Oct 11, 2025.
    24 changes: 24 additions & 0 deletions cleanup.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/usr/bin/env python3

    import time
    from pathlib import Path

    # Number of days to keep screenshots
    DAYS_TO_KEEP = 30

    # Get the script's directory
    script_dir = Path(__file__).parent

    # Calculate the cutoff time (30 days ago)
    cutoff_time = time.time() - (DAYS_TO_KEEP * 24 * 60 * 60)

    deleted_count = 0

    # Iterate through all PNG files in the current directory
    for file_path in script_dir.glob('*.png'):
    # Delete if older than 30 days
    if file_path.stat().st_mtime < cutoff_time:
    file_path.unlink()
    deleted_count += 1

    print(f"Deleted {deleted_count} PNG screenshots older than {DAYS_TO_KEEP} days")