View Single Post
Old 11-27-2014, 12:24 PM   #31
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,461
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Josieb1 View Post
I've had another go now my file is in Documents and this time the prompt just returned

C:\Users\Jenny>
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.

Last edited by chaley; 11-27-2014 at 12:29 PM.
chaley is offline   Reply With Quote