In Calibre You can select several books at once, and hit convert. It is an old feature, described on the official blog:
Bulk convert: Calibre allows you to convert books in bulk. You can
select a set of books, all of which may or may not be in the same
format, and convert them all in bulk to a different format. So say you
have a kindle and you have ...
You could also use Pandoc in conjunction with the kindlegen command-line tool.
Converting your HTML files to Markdown files is not necessary but if done will allow (easier) conversion to other formats should the need arise later on.
The table of contents can be automatically generated using Pandoc. Pandoc can export to the epub format which in turn can be ...