-
I would like to be able to have Templater create a new based on the title of the current file. For example, the current file might be named "Can't log into computer XYZ" and I want to then have Templater create a file named "Can't log into computer XYZ - address" with content
Is this possible using Templater? |
Beta Was this translation helpful? Give feedback.
Answered by
welpdx
Jan 23, 2023
Replies: 1 comment 4 replies
-
woohooo discussion #1000! Try this script: <%*
//get title and appends text to the end
const nameVar = tp.file.title + " - " + "address"
//searches for the [[template]] template to add template content
const templateVar = tp.file.find_tfile("template")
//create new file with filename and content from [[template]]
await tp.file.create_new(templateVar, nameVar)
%> In [[template]]: %%
tp.file.title gets the title.
split() gets the first half before the hyphen.
trim() removes whitespaces.
tR is the output, thats why we use \<\%*
%%
problem: [[<%* tR += tp.file.title.split("-")[0].trim()%>]]
# Solution ~welp |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
byerun
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
woohooo discussion #1000!
Try this script:
In [[template]]:
Demo
~welp