Clean up old events from ICS calendar files. Fully developed by my AI "Cloudy" (using model Kimi-K2.6).
Find a file
2026-06-16 23:31:32 +02:00
.gitignore Remove test files and add .gitignore 2026-06-16 23:31:32 +02:00
prune-calendar.py Initial commit: ICS calendar pruner 2026-06-16 23:31:24 +02:00
README.md Initial commit: ICS calendar pruner 2026-06-16 23:31:24 +02:00

ICS Calendar Pruner

Clean up old events from ICS calendar files locally.

Why

Calendar apps (Nextcloud, Google Calendar, etc.) accumulate years of events, making the ICS file huge and slow to load. This tool prunes old events while keeping your calendar structure intact.

Features

  • Local file processing - works on exported .ics files, no API access needed
  • Smart recurring event handling:
    • Events with UNTIL/COUNT (finite series) → removed if last occurrence is before cutoff
    • Infinite recurring events (no end) → skipped by default (safety)
    • Use --force-recurring to override
  • Default cutoff - 2 years ago from today (configurable)
  • JSON logging - track what was removed
  • Dry-run mode - preview changes before applying

Requirements

  • Python 3.9+
  • icalendar library: pip install icalendar

Installation

git clone https://code.leon.wtf/cloudy/ics-calendar-pruner.git
cd ics-calendar-pruner
pip install icalendar

Usage

# Preview what would be removed (default: 2 years ago)
python3 prune-calendar.py calendar.ics --dry-run

# Remove events before 2023-01-01, write to new file
python3 prune-calendar.py calendar.ics --before 2023-01-01 -o cleaned.ics

# Preview with custom date
python3 prune-calendar.py calendar.ics --before 2022-06-01 --dry-run

# Also write JSON log of removed events
python3 prune-calendar.py calendar.ics --before 2023-01-01 -o cleaned.ics --log removed.json

# Force removal of infinite recurring events (dangerous)
python3 prune-calendar.py calendar.ics --before 2023-01-01 --force-recurring

Workflow

  1. Export your calendar from Nextcloud/Google/etc. as .ics
  2. Run this tool to remove old events
  3. Import the cleaned .ics back (or keep as archive)

Safety

  • --dry-run shows what would be removed without touching files
  • Infinite recurring events are skipped unless --force-recurring is used
  • Original file is never modified; output goes to new file or stdout

License

MIT