'pandoc to make each directory a chapter

I have a lot of markdown files in various directories each with the same format (# title, then ## sub-title).

can I make the --toc respect the folder layout, in that the folder itself is the name of chapter, and each markdown file is content of this chapter.

so far pandoc totally ignores my folder names, it works the same as putting all the markdown files within the same folder.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source