#!/bin/bash
TODAY_DIR="$TICKLER_DIR/today/"
today=$(date '+%d');
thismonth=$(date '+%m');
defaulttext="check "
CFG_FILE=$HOME/.todo
[ -r "$CFG_FILE" ] || die "Fatal error:  Cannot read configuration file $CFG_FILE"
. "$CFG_FILE"

# copy all items into todo.txt and remove todays file
cat $TICKLER_DIR/days/$today/$today.txt >> "$TODO_FILE"
rm -rf $TICKLER_DIR/days/$today/$today.txt

# copy all items from folder with todays date to folder named 'today'
for i in $( ls $TICKLER_DIR/days/$today  ); do
	    echo $i
		mv $TICKLER_DIR/days/$today/${i} $TODAY_DIR/
		echo $defaulttext $TODAY_DIR/${i} >> "$TODO_FILE"
done

# copy all items into todo.txt and remove this months file
cat $TICKLER_DIR/months/$thismonth/$thismonth.txt >> "$TODO_FILE"
rm -rf $TICKLER_DIR/months/$thismonth/$thismonth.txt

# copy all items from folder from this month to folder named 'today'
for i in $( ls $TICKLER_DIR/months/$thismonth  ); do
	    echo $i
		mv $TICKLER_DIR/months/$thismonth/${i} $TODAY_DIR/
		echo $defaulttext $TODAY_DIR/${i} >> "$TODO_FILE"
done

touch $TICKLER_DIR/days/$today/$today.txt 
touch $TICKLER_DIR/months/$thismonth/$thismonth.txt 