Auto-generated file "table of contents"

It would be nice to have a command that generate a md file containing links to the entire contents of a folder. It would serve for me as a command center of sorts for a topic, where I could make notes about sub-topics without modifying the content of the sub-topics.

The obvious downside is when new content is added to the folder, what happens to this file “table of contents”? Updating the existing file could get complex but if the generator had a template and as long as the user did not modify the elements of the template, perhaps it would be easy to update.

Any non-markdown sequence of unique characters could denote a link.


In addition to folders, I’d like to see something like this that would populate an md file via tags. It would make creating a MOC easier.


The super nice thing about Obsidian is that your files and structure are not obsfucated or stored in proprietary file extensions. With everything in md files in a folder structure, you can do all manner of search/read/write functionality with external programs.

Got a long markdown file with tons of heading? Open that file in vscode with markdown plugins and it can create a ToC for that file automatically.

If you have a specific pattern (say a heading #1 at the top of each page/file) across files, you could have a python script read all files in a folder and search for that pattern, combine/manipulate them in memory and output an aggregate. Python is super fast when dealing with multiple files. This would give you an aggregate file that contains all of the H1 elements at the top of your page.

You could also limit this by also pages/files that have a specific tag then repeat for each tag you want. Only limit is your creativity.

1 Like

Yep, I’m hoping we’ll be able to drop a python script (whatever your flavor) into a plugins directory and run from there one day.

1 Like

Yes. Having integrated scripts to run and the ability to package those up on Git and share with the community like we currently have with themes would be super nice.
The good thing is that if you change content/names/etc of the .md files, obsidian will adjust and update. You can also edit any file in an external editor with the same behaviour. Having it all integrated though would be a nice quality of life.
If you have something specific in mind, I can look at coding something up for you and link to a git repository.

1 Like

Exactly. Thanks for the offer. I’m an old Linux sysadmin, so I like tinkering with a script now and again. :slight_smile: At the moment I haven’t got enough content in Obsidian to bother with writing anything, but at some point, I’m sure I will. It will be interesting to see what people come up with. :slight_smile:

Do you mean to imply that editing links externally also triggers Obsidian updating all links to the renamed file? I’m using other apps sometimes to modify files in my vault but I’ve never renamed one outside of Obsidian. It sounds interesting if files are tracked for changes outside like this.

1 Like

I use a simple AppleScript to generate an index for all my daily notes. On the Mac, I’ve setup folder actions to run this script automatically whenever a new file is added to the daily folder.

It’s a simple sorted index for now but I plan to update it to group by months and years. The two things I’ve been waiting to sort first,

  1. Support for remembering the state of folded elements so I can just have the current month open in the index
  2. Deciding whether to have all my daily journal entries in a single folder or having subfolders for months with their own indices.

I’m slightly inclined towards having subfolders since it bypasses the folding issue and is also cleaner in the file system. But the idea of a single index with all my entries is quite appealing. Or perhaps, a plugin with a calendar view might be most ideal but that’s a bit in the future.

1 Like

I think this plugin I created solves this in a little bit better of a way. Just search “Table of contents” in the community plugins


How is your AppleScript indexing going one year later? I’m still forming my process in Obsidian and beginning to question if I have what it takes to do the organization work seemingly required, as I search for “auto indexing” or some sort of AI/script generated map of content MOC or otherwise, lots of forum posts from July 2020 keep coming up. Wondering if I’m hunting down the wrong path.

I don’t use it anymore. I am now using the DataView plugin which dynamically generates indices/lists of all kinds. I use it to collect all sorts of logs from my daily notes (to track things I watched, people I met, etc.) For my daily notes, for the most part, the Calendar plugin is how I navigate it.

One quick tip though, if you use TOCs or indices and the like, it’s okay to have these dynamically generated lists/tables. But if you are particularly dealing with MOCs, it’s a philosophical difference in that part of what makes it work is you manually making/updating them. If you automate that part, a lot of the benefit somehow is wasted since the process encourages you to re-familiarise yourself with your notes and keep interacting with them in different ways over time.