Create and Move New Note with Templater

Hello.

I have a Templater template for creating dictionary notes:

<%*
  let title = tp.file.title
  if (title.startsWith("Untitled")) {
    title = await tp.system.prompt("Title");
    await tp.file.rename(title);
  } 
  tR += "---"
%>
tags: 
  - dictionary
  - writing
location: 
author: 
source: 
date: <% tp.date.now("YYYY-MM-DD") %>
created: <% tp.file.creation_date("YYYY-MM-DDTHH:mm:ss") %>
links:
  - "[[Categories]]"
category: "[[Dictionary]]"
summary: ""
---

# [[<% title %>]]

> [!info] **[[<% title %>]]** | pronunciation |
> 
> **type**   
> XXX
> 
> **ORIGIN**   
> XXX

OED: [<% title %>](dict://<% title %>)

If I add <% await tp.file.move("/Dictionary/" + tp.file.title) %> to the template (see below), the file is moved to the Dictionary folder, but I have to enter the file title twice.

<% await tp.file.move("/Dictionary/" + tp.file.title) %><%*
  let title = tp.file.title
  if (title.startsWith("Untitled")) {
    title = await tp.system.prompt("Title");
    await tp.file.rename(title);
  } 
  tR += "---"
%>
tags: 
  - dictionary
  - writing
location: 
author: 
source: 
date: <% tp.date.now("YYYY-MM-DD") %>
created: <% tp.file.creation_date("YYYY-MM-DDTHH:mm:ss") %>
links:
  - "[[Categories]]"
category: "[[Dictionary]]"
summary: ""
---

# [[<% title %>]]

> [!info] **[[<% title %>]]** | pronunciation |
> 
> **type**   
> XXX
> 
> **ORIGIN**   
> XXX

OED: [<% title %>](dict://<% title %>)

Is it possible to get the prompt for the file title to only appear once and for the file to be moved to the Dictionary folder?

With thanks :smiling_face:

Figure out the title before you even attempt to move it, and then do the move and rename in one swift go. Something like the following untested code:

<%*
 let title = tp.file.title
  if (title.startsWith("Untitled")) {
    title = await tp.system.prompt("Title");
  } 
  await tp.file.move("/Dictionary/" + title)
  tR += "---"
%>
1 Like

That is exactly what I wanted… Had read the Templater documentation, searched online, and tried countless versions of the code for hours without getting it to work. Very thankful for your help.

:clap: :heart_eyes: :pray: