1

I have a folder tree with varying folder levels and within each folder are a number of CHM files (Compiled HTML files). I would like a tool to batch convert all of these to EPUB (book) by just specifying the root of the folder tree and have the tool place the EPUB files in the same place as their CHM counterparts. The tool would recursively walk the folder tree to find each CHM and convert it.

I have already seen the question Software to convert CHM files to EPUB/Kindle and answers but this does not give me the ability to specify a root folder and have a tool traverse the subfolders finding each CHM and converting it. None of the tools mentioned do this.

The closest I can find to my requirement is: http://www.enolsoft.com/chm-to-epub-for-mac.html for the Mac (I am an owner of a MacBookPro and machines running Windows XP/7 and Linux). This is a reasonable price at 15$. this tool provides the facility to drag and drop files and place the converted file in the original source folder but it does not seem to provide the facility to just specify a root folder and have it do all the conversion of the files residing underneath this root. (If I don't get a better answer after leaving the question open for a few days then I would probably post this as my answer myself and accept.)

Both free and paid for are OK (as long as paid for is reasonable, i.e. about under 50$).

Mac, Windows or Linux, as long as tool is easy to use, proven and reasonably fast.

1 Answer 1

2

Calibre comes with the command line tool calibre-convert for converting various types of files, including CHM, to a variety of eBook formats (plus txt/html/rtf/pdf).

From there, it's trivial to extend that to operating on an entire hierarchy of files from your shell of choice (cmd.exe, PowerShell, bash, etc.).

9
  • +1 Thanks @afrazier your suggestion is feasible - I can write some treewalker code to recurse through the tree. However, it would be useful if Calibre (or elsewhere) have some example command line calls because there are a lot of parameters to consider ( I followed your link to get to CHM to EPUB conversion: manual.calibre-ebook.com/cli/… ). I would prefer not to have to experiment too much with the parameters to get best results as I would have to be checking the result of every CHM file I have, which is not ideal. Feb 13, 2012 at 14:32
  • ...and here's a nice way to walk a directory tree using Python (2.x). I shall use this: code.google.com/p/mylibs/source/browse/lib/Python/MyPyLib/… Feb 13, 2012 at 15:35
  • 1
    Probably the easiest way to figure out a useful command line would be to test out various settings in the GUI, then use the tip from this page to find out the command line used.
    – afrazier
    Feb 13, 2012 at 16:44
  • +1 Accepted. I'll go with this idea. I think I have all I need with your pointer to the Calibre command line tools documentation and the Tree Walker routine. Hopefully I will be able to get some good results without too much experimentation with the parameters. I may trial or even purchase (at 15$ it's very reasonable) the mentioned tool at enolsoft.com/chm-to-epub-for-mac.html for purposes of output quality comparison as well. Feb 13, 2012 at 16:48
  • 1
    Most shells make it trivial to run a command against a tree. For the Windows Command Prompt, you'd do something similar to: for /r %i in (C:\Path\To\*.chm) do @ebook-convert.exe "%~fi" "%~dpni.epub" [other options here] Nearly every Unix shell comes with looping constructs, find, xargs, and probably other ways to walk the tree without resorting to Python code. If you're most comfortable with Python, that's fine, but it's not necessary.
    – afrazier
    Feb 13, 2012 at 16:48

Not the answer you're looking for? Browse other questions tagged .