What I’m trying to do
I want to select a date with Natural Language Dates “Date Picker”, rename the note to the selected date and have it moved to a specific folder.
Things I have tried
<%*
let title = tp.file.title;
let picker = await app.commands.executeCommandById("nldates-obsidian:nlp-picker");
if (title.startsWith('test')) {
title = picker
await tp.file.rename(`${title}`); }
await tp.file.move("/Daily notes/" + tp.file.title)
-%>
I found this code here on this site, but I did not manage to make it work for my case.
I have also tried to create something with quickadd, because the date that was generated would get printed on the initial Note and not on the newly created one.
-
So cursor(1) gets activated. (No idea why it would not get normally activated after i run the template for the first time)
-
Is a capture to add: (Another variant I have tried…)
<%*
const title = tp.file.title
if (title.includes("test")) {
const newTitle = app.commands.executeCommandById('nldates-obsidian:nlp-picker')
await tp.file.rename(newTitle)
}
-%>
With the Quickadd setup I get the error: QuickAdd: (ERROR) TypeError: new_title.match is not a function.
Almost everything works, except that the date only gets pasted in the note, whilst the title stays the same.
I have no clue, why this does not work