Quote:
Originally Posted by eschwartz
I figured something out.
Save this code as a file, "calibre-add-format-blank-txt.py".
But first, see the bit in red? Change that to 'C:\\Users\Josieb1\\Calibre Library\\' or wherever your library is located, and make sure there are two backslashes.
Then run the following command in the command prompt:
Code:
calibre-debug.exe C:\path\to\wherever\you\put\calibre-add-format-blank-txt.py
Here is the code.
Code:
def init_cache(library_path):
from calibre.db.backend import DB
from calibre.db.cache import Cache
backend = DB(library_path)
cache = Cache(backend)
cache.init()
return cache
import tempfile
temporary_txt_file = tempfile.NamedTemporaryFile(suffix='txt', delete=False)
cache = init_cache(library_path = 'C:\\Users\\<username>\\Calibre Library\\')
for id in cache.all_book_ids():
cache.add_format(id, 'TXT', temporary_txt_file)
P.S. chaley, thanks for the similar python script you created in the templates, plugboards, custom columns thread a while back, you helped me figure out how to interface with calibre. 
Does this look good?
I decided it wasn't worth trying to deal with json on other peoples' machines  especially Windows, so it's all native calibre code.
Tested on a test library of mine, on a Win7 machine.
|
Thank you so much
I had a few problems getting the path right but eventually I got the message Welcome to the Interactive Calibre Shell. Does that mean its working?
I have nearly 6000 books so I don't know how long to leave it before I check in Calibre.