How to copy blocks from one note into another?

I know that I can create imbeds to blocks in other notes with

![[note-filename#^some-blockID]]

However, I want to be able to copy over the block, not link to it. In my case, I have a series of daily notes, which are just short bullet lists of the highlights of the day. I’d like to create a template that copies over the last 7 days worth of list items. Then I can just delete the less important ones, leaving only a few highlights for that week.

I even tried asking chatGPT and got this:

Obsidian uses a syntax called “Dynamic Blocks” to allow users to include and update content from other notes in their current note. Dynamic Blocks use the note name to identify the source note, so you can use the note name to automate the process of copying and inserting text from one note to another.

To use Dynamic Blocks with the note name, you can use the following syntax:

{{[note-name]}}

Replace “note-name” with the title of the note you want to include. When you save the note, the content from the other note will be inserted into the current note.

That did not work.

I don’t know of a way to do that. The nearest thing I know is: you can move blocks from one file to another using the core plugin Note Composer or the community plugin Note Refactor. I suppose you could use one of those to move the 7 days of items to the new file, then copy-paste them back the the original file and delete the non-highlights from there.

So are you familiar with the Templater plugin? Would it be an option for you to create a template which uses the javascript execution commands, <%* ... %> to actually perform various DataviewJS queries, and inserting those into the new note?

Here is a sample template to get you started, which when inserting the template pushes the persons from my test vault into a markdown list (and not a dynamic query):

<%*
 const dv = this.app.plugins.plugins["dataview"].api; 
 
  // Get your data to present...
 let list = dv.pages("#person").file.name.sort(n => n.name); 

  // Some random text to be added in the new page
  tR += `
## My main persons

Here follows some guys
`
  tR += dv.markdownList(list)
%>

For most plain markdown, you can just insert it into the tR variable like shown, and for some more specific dataview queries, there exists dataview markdown versions of the main functions.

1 Like