Gathering existing @searches for pasting into a new document

My workflows happen to use a number of TaskPaper files (different projects, different days), and whenever I start a new file, there are usually one or two existing @searches which I want to paste in from other TaskPaper files.

Here is a draft macro which just gathers existing @searches from:

  1. Any TaskPaper files which are open at the moment
  2. One or more default TaskPaper files which you can list in the macro.

It offers a menu (without duplicates) from which you can choose which @searches you want to paste into the active document.

2 Likes

You could also do something like this with TaskPaperRuby.

As a simple example, to grab all @search items from a certain “old” file, and append them to a “new” file gathered into a project called “Searches”, this would do it:

old_doc = TaskPaperDocument.open("~/Desktop/old.taskpaper")
search_proj = TaskPaperItem.new("Searches:")
searches = old_doc.all_items_with_tag("search")
search_proj.add_children(searches)

new_doc = TaskPaperDocument.open("~/Desktop/new.taskpaper")
new_doc.add_child(search_proj)
new_doc.save_file