It seems I had a bit of luck in a former test when moving files around, but it can be done with just one command, even though the tp.file.create_new()
is a little more finicky. It does depend on the folder parameter to already be created, but other than that it can create happily create subfolders as it executes (as long as it’s part of the filename).
Here is a working template, which only depends on the /01 - Journal
folder to exist.
<%*
const baseFolder = app.vault.getAbstractFileByPath("01 - Journal")
const filenameAndFolder = `${tp.date.now("YYYY")}/`+
`${tp.date.now("MM-MMMM/YYYY-MM-DD - ddd")}/`+
`Meeting--${tp.date.now("YYYY-MM-DD--HH-mm")}`
const template = tp.file.find_tfile("ExampleTemplate")
await tp.file.create_new(template, filenameAndFolder,
true, baseFolder)
%>
So add this as a template, connect the hotkey and/or button, and it’ll create the file with the content of the ExampleTemplate
. If you don’t want that template, just use ""
instead of template
when calling the tp.file.create_new()
.