Clean up old events from ICS calendar files. Fully developed by my AI "Cloudy" (using model Kimi-K2.6).
- Python 100%
| .gitignore | ||
| prune-calendar.py | ||
| README.md | ||
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
.icsfiles, 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-recurringto 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+
icalendarlibrary: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
- Export your calendar from Nextcloud/Google/etc. as
.ics - Run this tool to remove old events
- Import the cleaned
.icsback (or keep as archive)
Safety
--dry-runshows what would be removed without touching files- Infinite recurring events are skipped unless
--force-recurringis used - Original file is never modified; output goes to new file or stdout
License
MIT