Export Folder and File Name Conversion

With a document structure like below:
My Heading Level1
……My Heading Level2
…………My Doc 1
…………My Heading Level3
………………My Doc 1
………………My Doc 2

how can I export html or markdown files with the following convention?
my-heading-level1/my-heading-level2/my-doc1.html
my-heading-level1/my-heading-level2/my-heading-level3/my-doc1.html
my-heading-level1/my-heading-level2/my-heading-level3/my-doc2.html

In particular, all file/folder names are converted to lowercase, with spacial characters replace with -. And upper level headings are used as folder names.