Last active
January 8, 2026 18:33
-
-
Save HappyStinson/e8e39bfa8405993b2251eaa73e47af70 to your computer and use it in GitHub Desktop.
Combine ICS Files. This shell script combines multiple .ics calendar files into a single .ics file. It checks for existing .ics files in the directory, extracts the events from each file, and compiles them into one output file named combined.ics. Features: Automatically detects and processes all .ics files in the current directory. Retains the h…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Output file where all .ics files will be combined | |
| OUTPUT_FILE="combined.ics" | |
| # Check if any .ics files exist in the directory | |
| if ls *.ics 1> /dev/null 2>&1; then | |
| echo "Combining all .ics files into $OUTPUT_FILE..." | |
| # Start with an empty output file (or create a new one) | |
| > "$OUTPUT_FILE" | |
| # Add the header from the first .ics file up to (but not including) the first BEGIN:VEVENT | |
| first_file=$(ls *.ics | grep -v "$OUTPUT_FILE" | head -n 1) | |
| sed -n '1,/BEGIN:VEVENT/ p' "$first_file" | grep -v "BEGIN:VEVENT" >> "$OUTPUT_FILE" | |
| # Loop through each .ics file (excluding the combined output file) and combine them | |
| for file in *.ics; do | |
| # Exclude the output file from being processed | |
| if [ "$file" != "$OUTPUT_FILE" ]; then | |
| echo "Processing $file" | |
| # Extract the events only | |
| sed -n '/BEGIN:VEVENT/,/END:VEVENT/p' "$file" >> "$OUTPUT_FILE" | |
| fi | |
| done | |
| # Add the footer lines at the end of the combined file | |
| echo "END:VCALENDAR" >> "$OUTPUT_FILE" | |
| echo "All .ics files combined successfully into $OUTPUT_FILE" | |
| else | |
| echo "No .ics files found in the directory." | |
| fi |
Author
Thank you! Worked beautifully!
You are welcome. Merry Christmas!
I used this to combine a bunch of random calendar/ICS to populate a daily scribe calendar. Thx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!
Worked beautifully!