# awk support file for exporting emacs planner files to apple ical BEGIN { FS = " " } /^#[ABC]/ { outputfile = outputdir "/" $4 ".ics" category = "X-WR-CALNAME:" $4 head = "BEGIN:VCALENDAR\n" category "\n" tail = "\nEND:VCALENDAR" summ = "SUMMARY:" $3 if ($1 ~ /A$/) level = "PRIORITY:1" else if ($1 ~ /B$/) level = "PRIORITY:5" else level = "PRIORITY:9" due = "DUE:" time if ($2 ~ /X/) { status = "STATUS:COMPLETED\nCOMPLETED:" time "T060000Z" result = "BEGIN:VTODO\n" summ "\n" due "\n" level "\n" status "\nEND:VTODO" } else result = "BEGIN:VTODO\n" summ "\n" due "\n" level "\nEND:VTODO" system("if [ -e " outputfile " ]; then sed -i '$d' " outputfile "; echo \"" result tail "\" >> " outputfile "; else echo \"" head result tail "\" >> " outputfile "; fi") }