These are a few scripts I've used to help me out while writing a novel where each chapter is a markdown file. A repo might have a format like this:
book/
├── part-1
│ ├── chapter-01.md
│ ├── chapter-02.md
│ ├── chapter-03.md
│ ├── chapter-04.md
│ ├── chapter-05.md
│ └── chapter-06.md
└── part-2
├── chapter-07.md
├── chapter-08.md
└── chapter-09.md
More details in this blog post.