Looking for software that will batch convert a folder tree containing CHM files in different folders to EPUB

1

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.

therobyouknow

Posted 2012-02-13T12:43:21.310

Reputation: 3 596

Question was closed 2015-01-20T08:54:47.453

Answers

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.).

afrazier

Posted 2012-02-13T12:43:21.310

Reputation: 21 316

+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: http://manual.calibre-ebook.com/cli/ebook-convert-19.html#chm-input-to-epub-output ). 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.

– therobyouknow – 2012-02-13T14:32:28.617

...and here's a nice way to walk a directory tree using Python (2.x). I shall use this: http://code.google.com/p/mylibs/source/browse/lib/Python/MyPyLib/DirectoryStatWalker.py

– therobyouknow – 2012-02-13T15:35:00.300

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 – 2012-02-13T16:44:24.750

+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 http://www.enolsoft.com/chm-to-epub-for-mac.html for purposes of output quality comparison as well.

– therobyouknow – 2012-02-13T16:48:01.350

1Most 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 – 2012-02-13T16:48:57.600

+1 @afrazier on your response comment just saw this - this will help me get to optimal settings faster I think. – therobyouknow – 2012-02-13T16:49:03.127

I've started learning Python so real life projects that are useful to me gives me the incentive to learn (at least from other's code as is the case here if not yet from scratch.) Thanks for the other options (another +1 upvote) to run the command against a tree - I am aware there can be several options - thanks for sharing, they are enlightening and will be useful in other situations where Python is not available or for simplicity of their deployment in that installing it would not be necessary. – therobyouknow – 2012-02-13T16:52:07.973

Just for info: looking at what dpni and fi mean in your script examples - this helped me: http://stackoverflow.com/a/112120/227926 ( doesn't describe dpni but presumably dpni is a load of options all at once.) Also, http://www.dostips.com/DtTutoFunctions.php

– therobyouknow – 2012-02-14T16:04:06.270

Typing help call from a Command Prompt will tell you all that too. There's plenty of good built-in help at the Command Prompt. Also, use a single percent sign (%i) at a command prompt. Use double percent signs for named variables (%%i). Command Line parameters get single-percent numbered variables (%1, %2, ...). – afrazier – 2012-02-14T16:31:47.583