I’ve tried creating a new button using the built in button maker from the command palette, but the problem I’m running into is that the only way I have found to initiate a “Meeting Note” from the “Meeting Note Template” is to initiate from the following button:
```button
name My New Button
type command
action Templater: Create new note from template
This initiates the Templater pop-up where I select which template I want to create. The template I created does this:
But I don’t want to have to select which template. In this case, I will always select the Meeting Note Template, so how can I automate selecting this template instead of popping up the template selector?
In templater settings add your template to the Template Hotkeys section. You do not have to actually assign a key if you don’t want to, the important thing is it adds a command for your template. Now rather than using the command Templater: Create new note from template use the command for your template.
You’re brilliant!! Thank you for the quick response! That worked exactly as expected.
Edit: Actually, this triggers the template to run against the note where the button resides, not against a new note underneath the parent button, as expected. I need Templater (or the button) to create a new note, then run that templater command on the new note.
Have you tried looking into triggering templater when creating new notes in a given folder? This possibly in combination with standing in the correct folder (and creating new notes in the current folder), could possibly be an easier way to achieve what you’re aiming for.
It does depend a little on where you are when you want to create the meeting notes, aka where is currently this button of yours located? Is it in the same folder structure, or a different one?
Also, you might want to look into tp.file.create_new(), which allows you to create the file directly.
Finally, in your original script you do first a rename, and then a move. For later reference, the move command in itself is perfectly capable of doing the rename as part of the move operation, so the rename is superfluous.
If you look at the linked documentation to tp.file.create_new() in my previous post, you’d also see that you can include the folder where the new file is created. So there is should be no need for that extra tp.file.move() command.
I tried that first but it just kept giving me an error? Tried using app.vault.getAbstractFileByPath("FOLDERNAME") with every combination I could think of but it failed every time. If you have a working example I would like to see it as I would like to use this myself as well.
At any rate, it’s only one more line of code and it does work.
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.
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().
It took me a few test runs to discover this need of app.vault.getAbstractFileByPath for the folder to be created, and in the end I had to create the 01 - Journal, but when it was created, it was smooth sailing.