Swiss-army knife for iCalendar (ics) files.

iCalFilter provides grep and sed-like features for iCalendar files, as well as nice output formats.

Simple usage


$ icalfilter COMMAND input1.ics input2.ics > output.ics
$ icalfilter COMMAND input1.ics -o output.ics
$ cat input1.ics | icalfilter COMMAND > output.ics


Commands are separated by a semicolon (;).

Search (grep-like behaviour)

Only keep events that match the given regexp (g-lobal search):

$ icalfilter '/regexp/g' i.ics > o.ics
$ icalfilter '/LOCATION/g' i.ics > o.ics # keep events with a location.

For each event, keep only fields that match the given regexp (f-ield search):

$ icalfilter '/regexp/f' i.ics > o.ics
$ icalfilter '/SUMMARY|DTSTART|DTEND/f' i.ics > o.ics # only keep dates and
                                                      # summary.

Get events that match a date:

$ icalfilter '/>2011-11-11/' i.ics > o.ics

The operator must be one of <, >, = or ! (different than). You can also use a relative date:

$ icalfilter '/<-1d2m3y/' i.ics > o.ics # events before three years, two
                                        # months and one day ago.
$ icalfilter '/=+1w/' i.ics > o.ics     # events of the next week.

You can also truncate events that are on the search limit with the t flag:

$ icalfilter '/=+0d/t' i.ics > o.ics    # get only today events and truncate

Delete (grep -v-like behaviour)

You can use the sames patterns than in the search commands inverted by the d command:

$ icalfilter 'd/regexp/g' i.ics > o.ics # delete events matching regexp
$ icalfilter 'd/regexp/f' i.ics > o.ics # delete fields matching regexp
$ icalfilter 'd/<date/' i.ics > o.ics   # delete events before date

Substitute (sed s///-like behaviour)

The substitute command allow to change the value of a field matching a given regexp:

$ icalfilter 's/fieldregexp/newvalue/' i.ics > o.ics

Expand command

The expand command replace reccuring events by all corresponding single events:

$ icalfilter ':expand'


Default output

The default output is an iCalendar file, produced on the standard output. You can redirect the output to a file using the -o option.

Human output

iCalFilter provides a human-friendly formatted output, to have a nice timetable. Use the -H option to get this output (best used with a color option).

Colored output

iCalFilter can provide a colored output, for human output or pretty print (only available on UNIX systems).

Use the -c option to color each event with a randomly-choosed color for each input calendar.

You can instead provide a color configuration file with the -C conffile option. The color configuration file format is:

filepattern: colorname

where colorname is one of black, red, green, yellow, blue, purple, cyan, lightgrey, grey, boldred, boldgreen, boldyellow, boldblue, boldpurple, boldcyan or white.

Pretty print

In order to check the iCalendar output file, or for debugging purpose, you can use the -p option to get a pretty iCalendar output. This output may be colorized by the color system.


Instead of provide the command in the command line, you can use the -e option to provide a script filename.

In a script, you can put commands on different lines, without the need of ; separator.

You can also use # to start comments (but comments must be on their own line).

You can also use icalfilter -e in a shabang, and so write a script like:

#! icalfilter -e


# a comment


To run it:

$ chmod +x thescript
$ ./thescript i.ics > o.ics

See some script examples: <>