View Single Post
Old 08-06-2013, 12:38 AM   #10
Adoby
Handy Elephant
Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.
 
Adoby's Avatar
 
Posts: 1,737
Karma: 26785684
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Samsung Galaxy Tab S8 Ultra
Here is a minimal script to do the job. Written for bash. Tested in Ubuntu 13.04 with calibre 0.9.38.

Assumptions:
  • The original epub books are all in the folder ./books when the script is started. No other files are there, except the epub books.
  • Names of all fonts are in the file ./fonts.txt. One line per font name.
  • The fonts are installed in your system.
  • The original books are all in good shape and no fonts are embedded in them.
  • You will most likely wish to add more options to the ebook-convert command.

You can have as many fonts and books as you like.

The script will create a output directory ./books-FontName for each font and store copies of all the converted books, with the same name as the original books, with the font embedded as the base font.

Sample fonts.txt:
Code:
Liberation Serif
Bitstream Charter
DejaVu Serif
FreeSerif
The script:
Code:
#!/bin/bash
cat fonts.txt | while read FONT     # loop over font names in fonts.txt
do
   mkdir """books-$FONT"""          # create output direcory
   cd """books-$FONT"""             # and make it current
   for BOOK in ../books/*           # loop over the books
   do
      ebook-convert """$BOOK""" .epub --embed-font-family """$FONT"""
   done
   cd ..
done
I believe free/opensource versions of bash are available to install and run in Windows. I have not tested to see if the script works in Windows.

Last edited by Adoby; 08-06-2013 at 01:09 AM.
Adoby is offline   Reply With Quote