-
Hi there! I wanted all the folder within Mother folder to have a tag or property associated with the Mother folder. I have managed to rename the title using this code: <%*
const hasTitle = !tp.file.title.startsWith("Untitled");
let title;
let currentFolderPath = tp.file.folder(true);
let parentFolder = currentFolderPath.split("/").slice(-2, -1)[0];
if (!hasTitle) {
title = await tp.system.prompt("Número da Sessão");
await tp.file.rename("Sessão " + title + " - " + parentFolder);
} else {
title = tp.file.title;
}
_%> But I couldn't find a function to add a property or tag to the note. I was searching for something like: await tp.file.appendYalm("campanha", parentFolder); Can someone help me? Is there a way to do that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There's not a Templater function for that, but you can use Obsidian APIs. Here's an example from the documentation. <%*
tp.hooks.on_all_templates_executed(async () => {
const file = tp.file.find_tfile(tp.file.path(true));
await app.fileManager.processFrontMatter(file, (frontmatter) => {
frontmatter["key"] = "value";
});
});
-%> |
Beta Was this translation helpful? Give feedback.
There's not a Templater function for that, but you can use Obsidian APIs. Here's an example from the documentation.