![]() |
#1 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Dec 2016
Device: android phone
|
append custom field content to book comments
Can anyone suggest a way to append a custom field's content to the book comments? For example, I have a custom field for the page count and I want that to be prepended to the comments field. {page_count} + " pages" + {line_break} + {current contents of the comments field}
That would be useful to be able to retain some custom field data when exporting a book to be shared to others, because that custom field information can not be seen in the saved book. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Firstly, the custom field will be saved to the books metadata when you do a save-to-disk or send-to-device. Calibre updates all the metadata and another instance of calibre can read that data when you add the book to the library.
But, you can modify the core metadata fields with a metadata plugboard. These get run when calibre is sending the book outside the library. They are a template that can modify the field with other information. I do this to add information to the comments field that is not displayed on the Kobo devices. The template I use is: Code:
program: comment=field('comments'); rating_str = test($rating, strcat('<p><b>Rating:</b> ', rating_as_stars($rating), '</p>'),''); kobo_last_read_str = test($#kobo_last_read,strcat('<p><b>Last Read:</b> ', $#kobo_last_read, '</p>'),''); word_count = test(field('#words'),strcat('<b>Word count:</b> ', field('#words')),''); page_count = test(field('#pages'),strcat('<b>Page count:</b> ', field('#pages')),''); counts = test(strcat(word_count,page_count),'<p>',''); counts = test(word_count,strcat(counts,word_count),counts); counts = test(word_count,test(page_count,strcat(counts,' '),counts),counts); counts = test(page_count,strcat(counts,page_count),counts); counts = test(strcat(word_count,page_count),strcat(counts,'</p>'),''); extradata = strcat(rating_str,kobo_last_read_str,counts); comment=strcat(comment,test(extradata,strcat('<hr/>',extradata),"")); re(comment, '\s+', ' '); |
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
custom field based on multiple value field for export | nindotza | Calibre | 0 | 01-02-2021 08:37 AM |
Add Book Regex to Custom field | adept22 | Library Management | 3 | 10-07-2014 07:33 PM |
REQ: to Kovid - add "Append Comments" to batch Edit Metadata of entries | jecilop | Library Management | 2 | 09-02-2014 02:42 AM |
Book 'Comments' Field | mitch13 | Library Management | 5 | 04-19-2014 05:50 AM |
Regex Help - Add Book - Insert Filename into Custom Field | nynaevelan | Library Management | 3 | 10-12-2011 01:14 PM |