Templater hook for a specific kind of template? Bonus points for triggering template application when added to folder? (Zotero Integration flow)

I have a template called “foo” and every time I apply this specific template I want it to run a hook. The docs on hooks is very unclear and I can’t figure out how to specify which template I want to run another command; it seems right now that the hooks command is to run the hook on ALL templates.

My workflow is like this:
I use Zotero Integration to get a list of all my pdf annotations from Zotero; the plugin makes a new note and automatically puts into a folder called “Annotations”.

I then run a shell script to process all those into a specific format and separate files for each.

I want to be able to just add the “foo” template when the zotero note is created, and have it automatically trigger the script (I’m using shell commands plugin). Bonus points if this can happen automatically when the new annotations note is created in the “Annotations” folder.

You should probably use tp.file.include() rather than tp.hooks, as they serve different purposes, and the former seems more like what you want to do. tp.hooks is for hooking into Templater events, and currently, the only one available is on_all_templates_executed.

Have you even tried doing this using ordinary folder templates? If I’m not mistaken, given a new file created outside of Obsidian, then Obsidian will run the new file template on those files. In other words, you should be able to detect when a new file is added in that folder, and run a template which does whatever you want it to do. Including running some external shell script if that’s your desire.


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