Templater "Create file from template" results in an additional, empty file to be created and focused on


I am wrestling with templater for the last three days, on and off.

I am trying to create a new file, from template:

  1. Ask for file-name
  2. create note with said name
  3. populate it with template content (among which is tf.file.title)
  4. go to the newly created file
  5. stay in that file

Steps 1-4 work fine. Prompt opens, templater waits till I submit the prompt, then creates the file with correct name and populates the template successfully.

Step five doesn’t work so well. A second, empty, file called “untitled” is created immediately after, and that file is then opened. I then have to manually delete “untitled” so I don’t amass a million empty untitled’s at the root of my vault.

Optional steps I want to figure out how to do at some point:

  1. Move file into the folder my current note resides in when I called the templater.

I also cannot test if the tp.file.cursor() works because the focus is switched to a new file immediately

Source of the template to be filled in:

Name:<% tp.file.title %>
Tags:<% await tp.system.prompt("Set Tags, including hashtags and separating spaces") %>
[[MOC Player's Handbook|Back to the TOC]]

# <% tp.file.title %>
<% tp.file.cursor() %>

Source of the template i manually invoke by the create-from-template-modal:

<% tp.file.create_new(tp.file.find_tfile(“Template_DND_BookEntry”), await tp.system.prompt(“Set FileName”), true) %>

Any help is greatly appreciated.


1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.