How to get note name from property "Title"?

What I’m trying to do

Hello,
I’m using the Templater plugin, and I’d like to make a template that allows me, when I use it with the “create new note from template” command, to enter the title of the new note in a pop-up that not only fills in a “Title” property but also replaces with this entered title the default “Untitled” title of this new note. I’m pretty bad at programming…

Things I have tried

I’ve figured out how to enter the title in the property with <% tp.system.prompt(“Note title”) %> but I don’t know how to get it back for the note title… Thanks for your help.

Not an expert in Templater, but I had a similar problem, then I read somewhere that you can not name it, but you can rename it. This I have in my template …

<% await tp.file.rename("Week "+ moment().format("WW")) %>

… and will rename it after it is done.

Cheers, Marko :nerd_face:

This fairly untested but something like this should work :blush:
(If I understood correctly what you were trying to do :see_no_evil_monkey: )

<%*
const title = await tp.system.prompt("Note title");
await tp.file.rename(title);
-%>
<% "---" %>
title: <% title %>
<% "---" %>

Inspiration:

1 Like

Hello.

I have given up using Templater, but used to use the following to name notes and move them to a specified folder. Along the lines of what you need?

<%*
 let title = tp.file.title
  if (title.startsWith("Untitled")) {
    title = await tp.system.prompt("Title");
  } 
  await tp.file.move("/Notes/" + title)
  tR += "---"
%>
title: <% title %>
date: <% tp.date.now("YYYY-MM-DD") %>
created: <% tp.file.creation_date("YYYY-MM-DDTHH:mm:ss") %>
<%"---"%>

# [[<% title %>]]

Hello @DiCaver, @Pch and @Guapa ! Thanks for your help. I have finally made a mix of all your advices and done this :
<%*
let title = tp.file.title
if (title.startsWith(“Untitled”)) {
title = await tp.system.prompt(“Title”);
}
await tp.file.move(“/XXX/xxx/” + title)
tR += “—”
%>
uuid: <% tp.user.uuid() %>
title: <% title %>
author:

  • Jeronath
    created: <% tp.date.now(“YYYY-MM-DD”) %>
    updated: <% tp.file.last_modified_date(“YYYY-MM-DD”) %>
    category: XXX_xxx
    tags: yyy
    <%“—”%>

<% title %>

But I think that the Templater plugin may be too difficult for me to use, so maybe I would better find an alternative.
How do you create your templates ? Please share with me some good ideas :wink:
Thanks in advance for your replies !

2 Likes

I only use Templater (and pretty much always have) :sweat_smile: … So I wouldn’t be much help here :innocent:

Glad to know you’ve found a way to make your template wish come true though :blush: !

2 Likes