Hi everyone,
I want to improve my workflow for processing new content.
When I read a new article in Obsidian, I want to create highlight notes instantly, right where I encounter these highlights in the article.
I want to use Templater to do the following:
- Create a new note from a template.
- Give the new note a title. The title should be a concatenation of the original filename of the article + “_H” + i. Since I will likely encounter more than one highlight in the article, I want to append numbered suffixes. The first highlight gets the suffix “_H1”, the second highlight gets the suffix “_H2”, and so on. This is why I am using a while-loop and the “i” counter.
- Insert a link to the newly created file.
This is what I have tried, but I am not sure how to debug it, so I am not sure what the error is. I apologize for that, but I hope my description and code attempt are clear enough to get help from you.
Thank you in advance!
<%* //create a highlight-note from the highlight-note template (!!! not the TEMPLATER-template)
const template = tp.file.find_tfile("highlight-note template")
let i = 1
while (tp.file.exists(tp.file.path(true) + tp.file.title + "_H" + i) == true) {
i++;
};
const filename = tp.file.path(true) + "/" + tp.file.title + "_H" + i
const folder = app.vault.getAbstractFileByPath(tp.file.path(true))
await tp.file.create_new(template, filename, false, folder)
//create a link to the newly created journal note
tR += "![[" + filename + "]]"; %>