I want to create a note in a certain folder with a templater-shortcut. This already works with the following code, as long as a new (empty) file is open:
---<%* let person = await tp.system.prompt("person?") let task = await tp.system.prompt("task?") const filename = tp.file.creation_date("YYYY[-]MM[-]DD") + " " + person + " " + task await tp.file.rename(filename + ".md") await tp.file.move("office/" + filename) %> tag: meeting sus: <% person %> date: <% tp.file.creation_date("YYYY-MM-DD") %> folder: '<% tp.file.folder(true) %>' --- ## <% task %><% tp.file.cursor() %>
My problem: the content is apparently only appended before the file is moved. That’s why it goes wrong in many cases:
- the file is not empty → content is added and file moved
- any file in preview mode → this file is renamed and moved
- no file opened → error message ‘no active view, can’t append templates’.
tp.file.create_new I have been looking for a solution for hours. I can create a file but cannot access it afterwards (execute and open template).
Is there a solution for this at all? Many thanks for any hints!