Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script to generate a tpToday.taskpaper file containing all priority tasks from other taskpaper files.
import os
import io
import sys
import shutil
import re
import string
from datetime import date, datetime, time
# add as many taskpaper files as you want here
filelist = [
# this is where your today perspective will be stored
targetfile = '/Users/person/Dropbox/Elements/tpToday.taskpaper'
d =
today = d.strftime('%Y-%m-%d')
dt =
todayText = 'Last Run: ' + dt.strftime('%Y-%m-%d %H:%M')
regex = "((@+\\bcritical*)|(@+\\btoday*)|(@+\\bhigh)|(@+\\bdue\(" + today + "\)))(?!.*@done)"
for taskfile in filelist:
# open the file for reading
currFile = open(taskfile)
todayText = todayText + '\n' + 'Filename: ' + taskfile + '\n'
currentProject = ''
project = 'None'
# loop through the lines
for line in currFile:
# if you find a project
if line.find(':') != -1:
if line != project:
project = line
# if it isn't a project, look for the target regex
# add more here for extended date math
match =, line)
if match:
if project == currentProject:
currentProject = project
todayText = todayText + '\n' + project
todayText = todayText + line
# put the newly created text data into tpToday.taskpaper
todayFile = open(targetfile, "w")
# Now set up jobs in Lingon to run when any of your taskpaper files change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.