Triggering templater when a file's name is changed

I’m trying (in vain) to automatically rename a parent folder when a file within that folder is renamed so that the file and folder will always have the same name. I have no troubles doing that when the file is being created but, at the moment, I have to manually rename the folder when the file within it is renamed. Thus, I’m wondering if there’s any way to use a file name change as a trigger for Templater?

Given some javascript coding, I reckon you could piggy back on the on("rename", ...) event, as they talk about in the answer below.

From that callback you should be able to either trigger Templater, or perhaps just do the rename of the folder directly. However, I’m not sure whether that would trigger a loop since you then rename the file again from your callback.

Thread carefully when doing something like this. Very carefully.

1 Like

Thanks for the quick and very helpful reply! I’ve never added an event handler to Obsidian before so this may be beyond my pay grade, but I’ll let you know if I manage to make this work. (I’ll also let you know about the damage done if it doesn’t work!)

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