View Single Post
Old 11-27-2014, 12:18 PM   #29
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
Thank you. This is the name of the actual notepad file. I did select py as the save extension. I never amended the txt file extension

calibre-add-format-blank-txt.py

The file is now in the main Documents folder so the path is this

C:\Users\Jenny\Documents\calibre-add-format-blank-txt.py

so as far as I can tell my command prompt should be this

calibre-debug.exe C:\Users\Jenny\Documents\calibre-add-format-blank-txt.py

the Code within the Notepad file is as below:-

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\\Jenny\\Documents\\')


for id in cache.all_book_ids():
        cache.add_format(id, 'TXT', temporary_txt_file)
Does that look alright? I am sorry I just don't understand all this

Last edited by chaley; 11-27-2014 at 12:22 PM. Reason: Added code tags
Josieb1 is offline   Reply With Quote