From cc760471fc7e1ad008c8e461a826e8e1093183ff Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 31 Jul 2015 20:22:58 -0300 Subject: Adds calendar-archive --- calendar-archive | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 calendar-archive diff --git a/calendar-archive b/calendar-archive new file mode 100755 index 0000000..0b7b3df --- /dev/null +++ b/calendar-archive @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Remind rotator. +# + +# Parameters +CWD="`pwd`" +REMINDERS="$HOME/.remind" +YEAR_START="2009" +YEAR_END="`date +%Y`" +REGEXP="" + +# Setup +cd $REMINDERS + +# Archive old entries +for year in `seq $YEAR_START $YEAR_END`; do + REGEXP="$REGEXP -e /$year/d" + mkdir -p $REMINDERS/archive/$year + + for file in *.rem; do + grep " $year " $file > archive/$year/$file + done +done + +# Cleanup current reminders +for file in *.rem; do + sed -i $REGEXP $file +done + +# Teardown +cd $CWD -- cgit v1.2.3