Another program is no option.
I tried to write a batch script that would import my documents to Calibre.
First it uses LibreOffice to create the PDF and Calibre's ebook_convert
to create an EPUB from an ODT (LibreOffice Writer file).
> soffice.exe --headless --convert-to pdf --outdir /path/to/output /path/to/file.odt
> ebook-convert.exe /path/to/file.odt /path/to/output/file.epub
We can also use LibreOffice's EPUB conversion, which I presume employs epub2writer
since I have this tool installed. However, I found that ebook-convert.exe
creates nicer output that looks much like the original.
So the conversion part was suprisingly simple. Of course my batch-file is a bit more complex since I use an abstract subroutine for this task that dequotes pathnames, extracts the file basenames etc.
The next thing I had to do was to update Calibre's database. The essential command is:
calibredb.exe add --with-library /path/to/calibre-lib /path/to/output/file.epub
Alas, this works only the first time. Then it complains that the book already exists in the database. The --duplicate
option is no help because it will just add a 2nd, 3rd etc. instance of the same book! calibredb
misses a replace
command. The remove
command is not flexible enough since it expects some unknown numerical ids. The list
command will shows these ids in a human-readable form only, i.e. I see no way to extract the id in question from its output. Since calibredb
notices that the book is a duplicate, however, it should be very easy to replace it.
So please, can anybody help out here?