Automatically send tasks to your task-system

Problem

I frequently take notes where tasks are added. Then I would have to remember to transfer them to my todo-list which is not managed within Obsidian. So I wrote a script to do this for me automatically.

Solution

What the script does is that it takes all lines that you’ve tagged with a keyword (for example “#todo”) and sends each line in an email to the email address of your choice. For me I’ve chosen the email address for my task system inbox, so that I then process them there.

Example

Here is what it looks like in Obsidian. I add tag two lines with “#todo”. Once I’m ready for them to be transferred to my task-system I add the trigger “#task” which triggers the script to take action. The script takes the two lines with todo and sends to my task system, and replaces the tags to show that they’ve been processed.

Notes

This is just a small script I wrote to automate my own work. It is written in Powershell (first time ever I programmed in Powershell) and I can’t at all guarantee it will work well or not do any damage to your stuff. It works for me. That said, the script is short enough for anyone to easily read it through and make changes.

I would much appreciate if someone would make changes to the script in the future. For example adding a time when the keyword has been entered, that way no trigger would be needed anymore.

I’d be happy to have your feedback or know if you find this useful.

Link

Script and installation instructions here: https://github.com/Gnopps/ObsidianTodo. Requires Powershell (comes with most Windows-computers)

13 Likes

This is actually a great idea. I’m currently using TickTick to manage my tasks (not very well, I might add) and in the past I’ve hacked together solutions to get tasks in there via email (mainly as quick capture from Google assistant).
Tagging notes in Obsidian to send them straight to my task manager lets me prevent double-handling of writing things down then remembering to transfer them

Glad to hear that @death.au. So far the script has been working well for me but I think moving it into a plugin when the API becomes available would be better.

2 Likes

This is fantastic… hopefully one of the Mac people will right something similar as this is exactly what I am looking for, so I can send via eMail to OmniFocus. #Bravo

At the moment I am using [[Todo]] for open ToDo’s in my notes, and change them to [[Done]] when completed. I just need to figure out how to have them listed in the note and not just inn the backlinks section.

1 Like

I am looking at https://imdone.io/ the big advantage it focus on the same markdown file.

3 Likes

I might be able to do something like this with Hazel on macOS.

1 Like

The trigger could be - [ ] by default.

2 Likes

great idea, thanks for sharing

Did you succeed?

I would be quite interested in some Obsidian Hazel magic.

1 Like

Is there a similar solution for Mac users?

Can it send tasks to Todoist as well?

1 Like

Yes, it is possible to send tasks to any email address you specify.

1 Like

Yeah, i know abou this feature of Todoist, but do you mean I can do it directly from Obsidian?

Yes, check the instructions in the link in the first post. The script will email the task you tag in Obsidian do any email-address (including your Todoist-email).

Hey @Sailesh did you manage to use imdone nicely with obsidian? it looks great

Any Mac versions out there for this? If written in task paper format it should fill in all the details in, for example, Omnifocus, right? That would be awesome !

2 Likes

Thank you!! It is very inspiring. Using Task Warrior, with your approach, would require a simple task add ... . Some bash-fu should be sufficient.

Scheduling the event could also take advantage of existing os integrations with the file system - see https://github.com/emcrisostomo/fswatch or https://github.com/gorakhargosh/watchdog or https://github.com/inotify-tools/inotify-tools/wiki.

Below I paste a starting point for the actual (bash) script, converting #tw tagged lines within any Obsidian note into a proper Task Warrior event…

Yet, it remains to be seen how to launch (automatically) this script. It depends on the OS and its tricks to “notify upon file change” in a folder (see above the links I have shared).

On macOs (Big Sur) fswatch works well (home-brew) by invoking:
fswatch -o $HOME/Dropbox/notes | xargs -n1 -I{} myScript.sh
(see also the latency flag of fswatch)

Below the myScript.sh:

#!/usr/bin/env bash

#

# Path containing the md files to monitor..
myPath=$HOME/Dropbox/notes

# String to trigger the Task Warrior "add" command
trigger="#tw"

# String to replace the original trigger
trigrpl="#ok_tw"

# Remove these strings when creating the TW new task descr
extra1="- "
extra2="\[ ] "
extra3="\[x] "


# Use grep recursively, on all files (and subfolders)
# in $myPath, while ignoring binary files.
entries=$(grep -r -I "$trigger" $myPath/*)

# Use sed to remove any occurrence of $trigger & #extra1,2,3
clean=$(echo "$entries" | sed "[email protected][email protected]@g" | sed "[email protected][email protected]@g" | sed "[email protected][email protected]@g" | sed "[email protected][email protected]@g")

# Scan every line present in the output of grep
IFS='
'

for entry in $clean
do
  # Use this bash expansion trick to remove all chars
  # preceding the first ":" (see grep output format)
  # That would be the "line" used to create a new task
  if task add ${entry#*:} ; then
    #echo "Command succeeded"
    sed -i '' "[email protected][email protected][email protected]" "${entry%:*}"  
    # Only if TW succeeds, replace $trigger with $trigrpl
  fi
done

I’ve mashed code into this that makes it export to todo.txt, however I’ve run into a bug to fix before I publish. I’ve created an issue on github.
It would be nice to turn this into a proper plugin though

1 Like