Combine sections of multiple .md files by heading

I take daily notes in a markdown file (one file for each day). The headings of each file are the various projects I worked on that day. Would it be possible to write a script that:

  1. Takes a group of separate markdown files (daily notes)
  2. Extract notes based on a given heading (project name)
  3. Output a separate markdown file (project notes)

Yes. Certainly is possible.

When you say you take these daily notes in markdown files, you actually mean they are in Drafts as drafts, not some external files? Assuming that, a logical flow might look something like:

  • Tag your daily notes drafts as you make them. Leave them in the inbox.
  • Create a processing script that:
    • Queries for drafts with the daily note tag in the inbox
    • Loop over them scanning for the project headings and building an array of project notes for each project found
    • Save out those notes (maybe appending to existing project notes files?) stored somewhere (could be other drafts, could be files in iCloud, Dropbox, whatever)
    • Archives the daily notes files as “processed”.

The hardest part of that script is probably the logic to scan for notes, which may depend on how consistent you are adding project names, etc.