Automatiycally copy or embed content of a daily note?

A friend need to write infomation in a daily note, then copy or embed that info in other notes by tag or tittle. Any way to automatize this?

Things can be automated, but you need to clearly define what you are trying to do.

For help, you are probably going to have to give more information. Show some examples of the kind of daily note you are starting with. Show or tell what the final result is going to look like.

Before automating, can you write out a list of the exact steps you would take to do it manually? If not, then maybe it can’t be automated. If yes, then those steps can maybe be automated.

Ok, ok. I’ll try to explain it. This guy want write in his daily note (lets say 23-08) about diferent topics, like:

Topic1

observation about topic1

Topic2

observation about topic2

Like a journal i think, idk. Aniway, then he wants that H1 secctions automaticaly move, copy or embebed into several other notes, eg: In Topic1.md there are a new section:

20-08 notes

observation about Topic1
And in note Topic2.md now is:

20-08 note

Observation about Topic2

Sorry for my poor english, i apreciated any help

2 Likes

So it would get the new note name from the name of the header?

And if Topic 1 was repeated multiple times, what would happen? Add it to the existing note?

Do you have any examples of using a tag instead of a header?

There might be different ways to handle this. One way might be to use Dataview. And inside Topic 1, have an automatic search that searches your journal folder for any header that matches the title of the current “Topic 1” note and embeds those blocks. Or maybe Obsidian’s built-in embedded search can do that too.

Hopefully someone can answer with an idea. I’ll reply back if I figure it out.

Or do you prefer that the content is actually copied into the notes?

Hello,

Do you mean display contents of “Note A” inside “Note B”?

You can use the exclamation mark (!) in front of a file link to display that files contents inside a note

![[Note A]]

Does that fix it?

1 Like

Right, but I think the question is about making it automatic.

For that you might have to investigate embedding search results Embed files - Obsidian Help

Or Dataview (and maybe Dataviewjs)

And maybe also some Templater or similar plugins.

This is the automated method using templater:

<%*
const vault = app.vault;
const currentFile = await app.vault.read(app.workspace.getActiveFile());
const today = tp.date.now("DD/MM");

async function findFileByName(name) {
    const files = vault.getMarkdownFiles();
    return files.find(file => file.basename === name);
}

async function copyHeaderContent(header, content) {
    const fileName = header;
    const targetFile = await findFileByName(fileName);
    if (targetFile) {
        const targetContent = await vault.read(targetFile);
        const newHeader = `# ${today} (${fileName})\n`;
        const newContent = `${newHeader}${content}`;
        await vault.modify(targetFile, targetContent + "\n" + newContent);
    }
}

const headerRegex = /^#\s(.+)$/gm;
let match;
while ((match = headerRegex.exec(currentFile)) !== null) {
    const header = match[1];
    const headerContent = currentFile.split(match[0])[1].split(/^#/gm)[0].trim();
    await copyHeaderContent(header, headerContent);
}
%>

and you can but this in a template and make a shortcut to the template in templater settings and run it (the shortcut command) with a button using the button plugin however, make sure that the button or the script is not part of the header that contains the content to be copied because it will be copied as well.

Hello, thaks for your coments. Its hard to me understand codes of this complexity. So i try this:

I create a simple dataview thats display all subsections named “Class” in the daily notes thats link to a “resume note”. So in that resume note i put this code:

list without id file.name+"![["+file.name+"#"+"Class|]]"
from [[]]
where meta([["+file.name+"#"+"Class]]).subpath = "Class"
sort date DESC

Then i installed Dataview Publishe Pluggin that alows to write the dataview results in that note.

For my purpouse i edit the name of the results whit ![]. So when the pluggin write in the note, the results is embed.

So my friend would do this:

  1. open his daily note (with a propertie that link to [[resume note]]
  2. write in the seccion # Class

Then if he need to review several class he goes to “resume note” (where the dateview is) and execute the pluggin comand to embed the list of results.

Somethig like this:

I apreciate any advice to improve this thing. Even for aesthetic advices.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.