title_body: How can I create an ebook from existing HTML files?
upvoted_answer: 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 converted to mobi using the kindlegen tool. It's possible to write a bash script to automate the process.
  
  Sample command using Pandoc to export to epub:
  
  pandoc -o myBook.epub myBook.md --toc \
  --epub-cover-image=cover.jpg \
  --epub-stylesheet=myStylesheet.css \
  --number-sections