aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2015-07-31 20:22:58 -0300
committerSilvio Rhatto <rhatto@riseup.net>2015-07-31 20:22:58 -0300
commitcc760471fc7e1ad008c8e461a826e8e1093183ff (patch)
tree856028e0269239aa34cba44651e2076cf284bfbe
parent3d802bfe0c3afb8b2bab044a71ad47de5507442a (diff)
downloadutils-calendar-cc760471fc7e1ad008c8e461a826e8e1093183ff.tar.gz
utils-calendar-cc760471fc7e1ad008c8e461a826e8e1093183ff.tar.bz2
Adds calendar-archive
-rwxr-xr-xcalendar-archive32
1 files changed, 32 insertions, 0 deletions
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