![]() |
#1 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 364
Karma: 1035291
Join Date: Jul 2006
Location: Redmond, WA
Device: iPad Mini,Kindle Paperwhite
|
Adding new formats
Hi all
For each of my epub books, I have generated a summary as a.txt plaintext file, in the same folder. I'd like these to show up as an additional format in the entry for each book. However, I don't see how to do this. Using Library Maintenance I can find them as "Extra book formats" but the only option seems to be to delete them, not add them. Is there are good solution to this? Thanks G |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,611
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
If you press shift-a, you can navigate to, and select the txt file. It is a recognised format so you should be able to add it easily.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,718
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
In future use the Add Books->Add an empty file to selected book records option to create the TXT file and then edit it.
Assuming the files are in the book folders and named summary.txt, you could open the book folder, drag-n-drop the summary.txt file onto the book details panel, and then delete the summary.txt file. Added: tested in version 6.22. BR Last edited by BetterRed; 07-07-2023 at 01:27 AM. |
![]() |
![]() |
![]() |
#4 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 364
Karma: 1035291
Join Date: Jul 2006
Location: Redmond, WA
Device: iPad Mini,Kindle Paperwhite
|
Thanks for these suggestions. Unfortunately I am really looking for a bulk method; I have a large library and doing this one by one would be pretty tedious.
Sounds like I would need to make a PR against Calibre. |
![]() |
![]() |
![]() |
#5 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
One possible way is to Use Copy to Library (delete after copy) to (a)NewLibrary what is left is your problem books ![]() |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,969
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
First, move all the text files out of your library folder. I suggest use a bulk-renamer to rename them to the folder name and then move them somewhere else. (They aren't registered in the Calibre database so it shouldn't cause any issues, as long as you're careful to limit it to the txts.)
Get Action Chains plugin. Make a new chain. Single-field edit on formats, this template (swapping out D:\Whatever\ for your somewhere else): Code:
D:\Whatever\{title} ({id}).txt EDIT: You may be able to skip the 'copying them all out and bulk-editing' by repliating the library path with a template. I don't know how to do this. I don't know what will happen if the file doesn't exist. Last edited by ownedbycats; 07-08-2023 at 01:39 PM. |
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
If you know how to code well enough to make a PR (github Pull Request) against calibre then you should be able to write a script that does the work. The script would walk the library looking for an a.txt file (or whatever it is named) in the book folder. When it finds one then it uses the calibre API method cache.add_format() method to add it as a book.
After verifying that the script worked, delete all the a.txt files. This script might be a place to start. Code:
import os from calibre.library import db as DB lib_path = sys.argv[1] db = DB(path = lib_path) cache = db.new_api # Get the normalized library path library_path = cache.backend.library_path for book_id in cache.all_book_ids(): # Construct the full path to the book folder path = os.path.join(library_path, cache.field_for('path', book_id).replace('/', os.sep)) # Check if the file a.txt is in that folder txt_file = os.path.join(path, 'a.txt') if os.path.exists(txt_file): # It is. Add it as a format cache.add_format(book_id, 'txt', txt_file, run_hooks=False) print('added', txt_file) Of course, back up your library before running it! Last edited by chaley; 07-08-2023 at 01:45 PM. |
![]() |
![]() |
![]() |
#8 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 364
Karma: 1035291
Join Date: Jul 2006
Location: Redmond, WA
Device: iPad Mini,Kindle Paperwhite
|
That's a good option. It may still be worth a PR though; it seems like missing functionality in the database repair options. If I have a format not in the DB, it seems reasonable to want to either add it to the database or delete it from the file system; right now only the latter is available.
|
![]() |
![]() |
![]() |
#9 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
If you want to take this on then have at it, but bear in mind that in this case "you touched it last". ![]() |
|
![]() |
![]() |
![]() |
#10 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 364
Karma: 1035291
Join Date: Jul 2006
Location: Redmond, WA
Device: iPad Mini,Kindle Paperwhite
|
Fair enough, you''ve scared me off. I'll stick to a script for my own purposes. :-)
|
![]() |
![]() |
![]() |
#11 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
|
Quote:
If you do this, you could script "read the text file and assign metadata field" (via calibredb, or possibly within calibre itself -- I haven't worked with action chains, and I'm still pretty new to python) Last edited by kjdavies; 09-15-2023 at 01:04 PM. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding the same book in different formats | Rellwood | Library Management | 3 | 01-04-2021 11:03 PM |
Adding formats to a book? | edhasted | Conversion | 3 | 05-28-2013 02:49 PM |
Problem adding additional formats | Loosheesh | Calibre | 16 | 05-12-2013 08:06 AM |
Adding formats to catalog | kamanza | Library Management | 5 | 09-14-2012 02:25 PM |
Adding the same title, but different formats... | Frodolass | Calibre | 3 | 12-13-2009 05:44 AM |