Trigger markdown file creation when other file is created

Things I have tried

  • searched in the official obisidian help
  • looked for a community plugin

I want to use obsidian to document a software project. Therefore I was looking for a solution that creates a markdown file whenever I add a file to the software project itself.

Example: In the folder “Test” I create a file with Visual Studio/VS Code/Notepad++ “test.c”. Then I want to automatically have the file “” created.
If it would be possible to use a template based on the filetype this would be even better. “test.c” would use a different template than “”.


I’m not sure if this can be handled by only tools within Obsidian or not. You’re talking about sharing the vault files in between various source files (and possibly binary files), so that could possibly become a little messy.

There is an option in Obsidian to show all file extensions, and not just .md, I reckon that’s something you need to turn on. Enable that in Settings > Files & Links > Detect all file extensions. Its documentation says: Show files with any extension even if Obsidian can’t open them natively, so that you can link to them and see them in File Explorer and Quick Switcher.

To create corresponding markdown files, I see three alternatives: Hook on to the event which detects new files in the vault, scan for all files and create corresponding markdown files, and externally use the make system of your coding environment create corresponding markdown if needed.

Event detection

I’ve not done too much of this, and this kind of belongs in a plugin, but events are sent by Obsidian when various stuff happen, and I reckon there is an event for when a new file is detected as coming into the vault. This event is possible, with some coding experience, to handle and create a new file (if it doesn’t exist from before) with a corresponding template.

Scan files

Maybe a little easier would be to write Templater execution commands to scan the vault directories for all files, and see which source files are present, and if the corresponding markdown files is present. Since this is already within Templater, it’s easy to then create the new files and applying templates to them.

This wouldn’t be automatic though, but I reckon you don’t create that many new files, so you could survive running such a script every now and then. And it can be made automatic in the sense, that you don’t need to give it any guidance as to which files you’ve created, you just start it, and watch magic unfold.

Using the make system

Most modern coding environments have a makefile system, which is possible to configure such that in addition to compiling the files, they could do stuff like creating markdown files as well. However, this option is kind of on the side of Obsidian and this forum.

This could however be made fully automatic, and it could possibly handle some template specification when creating the files. Still, when Obisidian detects the new file, you could then re-apply some template using Templater’s detect new file creation, so it could handle that bit.

So there you have some options, I think maybe the first and last are kind of heavy if you don’t know either of those environments beforehand. Hooking on to an event would however provide the best solution, I think.

The middle option should be somewhat achievable with some coding experience. I’m imagining something along the following lines:

  • Scan all files in vault with interesting extensions, .c, .py, and so on
    • If a file is found, check if the corresponding markdown file, i.e. exists
    • If it exists, skip to next
    • If it doesn’t exists, use tp.file.create_new() to create a new file, with the corresponding template based on the file extension

After writing this script, hook it up to a hotkey, and hit that every once in a while when you’re creating new source files.

1 Like

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