Move projectless tasks at top of file to Inbox project

I use ComplexPoint’s excellent Keyboard Maestro script for creating new tasks. It is perfect for me.

I also enter tasks through Drafts on my iPhone. But the tasks are prepended to the file, and I’d like them to end up at the top of my Inbox: project, as ComplexPoint’s script does.

So I need to take the tasks at the top of the file – those without a parent project – and move them into the Inbox project.

Could someone point me in the direction of how I’d do this? Would it be a JS I run every time my TP file updates from Drafts? On a schedule of every few minutes? From an on-demand Keyboard Maestro script? I think there’s an elegant way to do it, but I’m not good enough to know what event to use, which technology to use, etc. If someone might tell me that much, I’d take a stab at the solution.

Thank you.


1 Like

I’d do it when you first add it. Here’s how I did it in python for an Alfred workflow:

import sys

filename = sys.argv[1]
theNewItem = sys.argv[2]

theFile = open(filename,'r')
firstLine = theFile.readline()
theNewLines = [firstLine, '\t' + theNewItem + '\n'] +  theFile.readlines()
print theNewLines
theFile = open(filename,'w')

basically you’re just taking the first line of the file (which is presumed to be “Inbox:”), sticking the new line after that, than adding on the rest of the file. Translation to Javascript is left as an exercise for the user :slight_smile:

Looking at my phone, I also used to have Drafts call an Editorial workflow which would open the TP document, and move the cursor to the correct position and type the text. Lots of ways to skin a cat.