iCalendar `.ics` file cleaner

Summary

ics-file-cleaner is a Bash script, to clean up iCal exports for re-import into other calendar applications.

When completing calendar migrations from a email hosting platform to another, we typically utilise iCal / Calendars to export an .ics file from the user’s current account to then be imported into the new account.

Most found problem: Duplicate UID’s entries.

ics-file-cleaner will run through an exported .ics file stripping out:

Usage

  1. Export the Calendar in question as an ics file.

  2. Launch the ics-file-cleaner script:

    $ ./ics-file-cleaner.sh myCalendar.ics Success!

Script

#!/bin/bash

BIN_SED=`which sed`

if [ -z $BIN_SED ];
then
  echo sed not found or not in PATH
  exit 1
fi

Ret=0

sed -i.orig '/UID/d' $1 || Ret=$?
#sed -i.bak '/ORGANIZER/d' $1 || Ret=$?
#sed -i.bak1 '/ATTACH/d' $1 || Ret=$?

if [ $Ret -eq 0 ];
then
  echo Success!
else
  echo Oops! Returnvalue=$Ret
  exit $Ret
fi

exit $Ret

Credits

Inspired by iCalVerter.

License

ics-file-cleaner is free software, available under the GNU Affero General Public License, Version 3.