Created
June 22, 2013 20:23
-
-
Save dap/5842439 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/perl | |
# | |
# Updates UID's listed in an .ics file | |
# | |
# Written to address the problem of importing calendar entries from an .ics | |
# into a Google Calendar, deleting them all, then finding that Google Calendar | |
# will not allow reimporting entries that it's already seen. | |
# | |
# This program updates the .ics in place, so make a backup copy first. | |
# | |
# Invocation: | |
# | |
# $ ./update_ics_uids.pl /tmp/your_entries.ics | |
# | |
use perl5i::2; | |
use IO::All; | |
use Data::UUID; | |
func main { | |
die "Must specify a filename to modify in place." unless | |
$ARGV[0]; | |
my $ical = io $ARGV[0]; | |
my $ug = Data::UUID->new(); | |
for (my $i = 0; $i < $#$ical; $i++) { | |
if ($ical->[$i] =~ m/^UID:/) { | |
$ical->[$i] = 'UID:' . $ug->create_str() . "\n"; | |
} | |
} | |
} | |
main() if $0 eq __FILE__; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment