Automatically trigger a templater folder template after having use templater to move the note in this folder

What I’m trying to do

I’ve created a “choice folder” that’s part of my automation process. If a file goes to this folder, templater make a prompt that allows me to choose between differents options (in that case author, personnality, contact in French) which will define in which folder I want to move the file.
According to the choice, Templater will move the file in the right folder.
Each of those folder are set in a way that they have their own template and templater will apply those templates if a file is created inside them.

My script works well to make the choice and move the file in the right location but once this is done, templater does not apply the template related with the folder of destination. I think it is easily fixable, but I don’t find the command to tell templater “hey ! Just consider it’s like a new file”

NB : My note will be blank so I don’t care if it’s content is erased

Things I have tried

Here is my script

<%-*  let filetype = await tp.system.suggester(["Auteur", "Contact", "Personnalité"], ["Auteur", "Contact", "Personnalité"]); -%>
<%-* let myFilePath = ""; -%>

<%-* if (filetype === "Auteur") {  -%>
<%-*   myFilePath = "SOURCES/Auteurs/" + tp.file.title; -%>
<%-* } else if (filetype === "Contact") {  -%>
<%-*   myFilePath = "2 - AREA/CRM/Contacts/" + tp.file.title; -%>
<%-* } else if (filetype === "Personnalité") {  -%>
<%-*   myFilePath = "SOURCES/Personnalité/" + tp.file.title; -%>
<%-* }  -%>

<%-* await tp.file.move(`${myFilePath}`); -%>

Hope someone could help me and sorry to disturb you with that. I don’t know how to code so it take me hours to solve such littles problems

1 Like

Asking the obvious here:

Are the rest of the Folder Templates properly set up?
E.g.:
image

You need to have templates for folders “SOURCES/Auteurs/”, “2 - AREA/CRM/Contacts/” and “SOURCES/Personnalité/” set up.

Hi @gino_m,
Yup as you can see


I tested each folder and templates are working. The only case in which they aren’t trigger is when I use my script to move files

How about using a Prompt Template with
<%-tp.file.include("[[template_name]]")-%> lines
in an if - else if - else conditional trio? This way you can default back to a template that you can use for anything else.

<%-* let filetype = await tp.system.suggester(["Auteur", "Contact", "Personnalité"], ["Auteur", "Contact", "Personnalité"], false, "Which template do you want to use?") -%>
<%-* if (filetype === "Auteur") {  -%>
<%-tp.file.include("[[Templatename1]]")-%>
<%-* } else if (filetype === "Contact") {  -%>
<%-tp.file.include("[[Templatename2]]")-%>
<%-* } else if (filetype === "Personnalité") {  -%>
<%-tp.file.include("[[Templatename3]]")-%>
<%-* } else { -%>
<%-tp.file.include("[[DefaultTemplateName]]")-%>
<%-* } -%>

But you could incorporate the template in a meta templater.
I set it up using this guide many moons ago:

1 Like

I had this idea by looking at this video (meta template). The problem is that I find the meta template not flexible enough and not easy to install for people who struggle with code. So if I have to modify the code each time I want to change template it’s not the best for me. That why I want to use the "automatic template in a folder* of templater.
I prefer to use auto note mover and quick add to organize my notes.
In a way, the issue I’ve encounter is not that problematic but I don’t understand why it’s isn’t working and it can be a problem for me for futur projects

@Mathunter if you’re struggling to get things working by moving notes into folders, you might find it easier to do it the other way around - and have the new note be automatically created in the right folder depending on the template.

Here’s how I do it:

:point_right: Alan’s one-stop-shop New Note script

You put all your different types of new-note templates in a single folder, and the script will present them to you as a list and you just choose one and start working:

Each type of template can optionally specify the folder it will use to make the new note, using a Property in the template.

This way it doesn’t require any programming skills at all - all you need to do is add your different types of templates to a folder, and you’re ready to go.

That’s what I do. See the first block here:

It doesn’t take a programmer to make changes to code already working. And one can easily buff up the meta templater contents to dozens of different templates. All one needs to be mindful is of putting the new items in the proper places.
But I don’t force a pudding that doesn’t taste good.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.