Hey everyone,
Thanks for taking the time helping a newbie I do not have a lot of coding experience, but have tried multiple commands in Templater trying to fix my problem.
What I would like to achieve:
Upon triggering the Templater template hotkey, create a new note from specific template - this works fine.
Trigger a text prompt to do two things:
2.1. Rename the file with the text entered in the prompt.
2.2. Create a header in the note copying the file name.
Move the file into a specific folder (here named βProjectsβ).
β¦ not necessarily in this order
Things I have tried
My (relevant) setup:
Obsidian 1.0.3
Templater 1.16.0
I have tried (and achieved) various components of my target state, but not the combination. For example, my current version (copied from here ) gives me a text prompt and shifts the note, but only a creates a YAML header and note header with the entered text, but does not rename the file!
<%*
let title = tp.file.title
if (title.startsWith("Untitled")) {
title = await tp.system.prompt("Title");
await tp.file.rename(title);
}
tR += "---"
%>
title: <%* tR += title %>
created: <% tp.date.now("dddd Do MMMM YYYY HH:mm") %>
Last modified: <% tp.file.last_modified_date("dddd Do MMMM YYYY HH:mm") %>
Aliases:
Tags:
---
# <%* tR += title %>
### Summary
<% await tp.file.move("/Projects/" + tp.file.title) %>
### Notes
-
### Flashcards
-
### References
**Source / author**::
**Link**::
<div class=iframe-container>
## Place the embedded link from YouTube in the indented section here.
</div>
I think I read somewhere that there is a delay before the tp.file.title gets updated, so one alternative is to use title in the move command. Another option, is to just skip the rename command and use the move command to also rename the file.
Hey @notralph - thanks for your answer! I replaced the upper part of the code (kept the header), and got the two prompts but it did not seem to work. The file is still βUntitledβ in its name. This is what I got:
==2022-11-27==
# Test
### Summary
### Notes
-
### Flashcards
-
### References
**Source / author**::
**Link**::
<div class=iframe-container>
## Place the embedded link from YouTube in the indented section here.
</div>