aboutsummaryrefslogtreecommitdiff
path: root/calendar-archive
blob: bfa71b99887a5e79dce7c39ea62f25e4d8dac2a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
#
# Remind rotator.
#

# Parameters
CWD="`pwd`"
REMINDERS="$HOME/.remind"
YEAR_START="2009"
YEAR_END="${1:-`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