If I right click a folder and select “New note” Obsidian makes a new note, templater inserts the date, but the cursor is stuck in the title right before the date. Not sure why this happens. Also, if I right click the folder and select New note from template I get a “Template parsing error”.
Yes, I have made a template, pasted your code. When I run it it does not work. Also, I am not sure what you did in your GIF it looks like you are using a completely different method. You are replacing the template whilst I am trying to make a folder template.
<%*
const date = tp.date.now("YYYY-MM-DD");
const newFileName = `${date}-${tp.file.title}`;
// Check if the file already exists
const existingFile = app.vault.getAbstractFileByPath(newFileName + ".md");
if (!existingFile) {
await tp.file.rename(newFileName);
// Wait for the editor to be ready
await new Promise(resolve => setTimeout(resolve, 100));
const editor = app.workspace.activeLeaf.view.sourceMode.cmEditor;
editor.setCursor({ line: 0, ch: 0 });
} else {
new Notice("File with the same name already exists!");
}
%>