Automatically transfer Logseq’s yesterday’s to-do items to today

Original link: https://blanboom.org/2023/logseq-yesterday-todo-transfer-to-today/

Although Logseq provides a powerful Query function that can summarize and display the to-do items on all pages, I am more accustomed to organizing the to-do items in a more cumbersome way: the next morning, manually add the unfinished to-do items from the previous day. Items are transferred to the current day’s log page, and only notes and completed tasks remain in the previous day’s log.

I’ve been using this method to manage my to-do list for over a year, and it allows me to review what I accomplished the day before and refresh my tasks for the day. Overall, I am quite satisfied with this method, but the repeated copy-paste operations every morning are indeed a bit troublesome…

Therefore, I want to use a “semi-automated” method to make this process smoother: that is, through a script, automatically transfer the unfinished to-do items from the previous day to today.

Since I’m not familiar with Logseq plug-in development, I tried letting ChatGPT generate a shell script to accomplish this task:

 #!/bin/bash yesterday=$(date -d "yesterday" "+%Y_%m_%d") today=$(date "+%Y_%m_%d") input_file="${yesterday}.md" output_file="${today}.md" temp_file="temp.md" awk ' BEGIN { RS = "\n"; FS = "\n"; ORS = "\n"; print_flag = 0; } { # 确定哪些block 从昨天转移到今天。可根据自己的使用习惯修改此处if ($1 ~ /^- (TODO|DOING)/) { print_flag = 1; } else if ($1 ~ /^- /) { print_flag = 0; } if (print_flag == 1) { print $0 >> "'"$output_file"'"; } else { print $0 > "'"$temp_file"'"; } } ' "$input_file" mv "$temp_file" "$input_file"

After testing, the script works perfectly. I mainly use Logseq on Windows, so I installed Git for Windows, then created a shortcut for this script and added it to the start menu. From now on, I can directly click the shortcut in the start menu every morning to realize the automatic transfer of to-do items.

Of course, this method also works with Obsidian, or other similar plain text note-taking tools.

This article is reproduced from: https://blanboom.org/2023/logseq-yesterday-todo-transfer-to-today/
This site is only for collection, and the copyright belongs to the original author.