View Single Post
Old 11-27-2014, 12:34 PM   #32
Josieb1
Grand Sorcerer
Josieb1 ought to be getting tired of karma fortunes by now.Josieb1 ought to be getting tired of karma fortunes by now.Josieb1 ought to be getting tired of karma fortunes by now.Josieb1 ought to be getting tired of karma fortunes by now.Josieb1 ought to be getting tired of karma fortunes by now.Josieb1 ought to be getting tired of karma fortunes by now.Josieb1 ought to be getting tired of karma fortunes by now.Josieb1 ought to be getting tired of karma fortunes by now.Josieb1 ought to be getting tired of karma fortunes by now.Josieb1 ought to be getting tired of karma fortunes by now.Josieb1 ought to be getting tired of karma fortunes by now.
 
Posts: 5,090
Karma: 18051062
Join Date: Nov 2009
Location: UK
Device: Kindle Scribe, Coloursoft, PW SE, Kindle 6, Kobo Libra 2, Clara BW
Quote:
Originally Posted by chaley View Post
Did it add any txt formats?

EDIT: you didn't specify your library correctly.

Change the program to the following, being sure that the path to the library is correct.
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

print('Starting adding txt formats')
import tempfile
temporary_txt_file = tempfile.NamedTemporaryFile(suffix='txt', delete=False)

cache = init_cache(library_path = 'C:\\Users\\Jenny\\Documents\\Calibre Library')

print('Starting loop')
for id in cache.all_book_ids():
        cache.add_format(id, 'TXT', temporary_txt_file)
print('Finished')
When you run the script you should see some output from the three print() statements.
ohh I see what you mean , let me have another go. If this ever works i'll write up some notes!
Josieb1 is offline   Reply With Quote