![]() |
#556 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Out of curiosity, is Action Chains single-field edit the only method for updating a non-composite field from a template?
|
![]() |
![]() |
![]() |
#557 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,459
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
No, although it might be the best option depending on what sort of changes you are making. You can use Edit Metadata Bulk S&R with the source as a template. If you are brave you can the template tester with Python templates, although you will need to tell the GUI about the changes -- reseting the tag browser, cleaning up user categories, and refreshing the book list.
|
![]() |
![]() |
![]() |
#558 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Search & Replace sounds more useful for one-off edits, and Action Chains for using it on a semi-regular basis
![]() |
![]() |
![]() |
![]() |
#559 | |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Quote:
When using an if-then in S&R should I need to add an 'else $columnname' to return the original value to prevent nulling it out? EDIT: It looks so. Last edited by ownedbycats; 04-05-2023 at 12:29 AM. |
|
![]() |
![]() |
![]() |
#560 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,459
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#561 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,459
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
python: def evaluate(book, context): args = context.arguments if args is None or len(args) != 1: return 'Invalid arguments' try: sidx = float(args[0]) except: return 'Bad series index' db = context.db from calibre.gui2.ui import get_gui gui = get_gui() bids = gui.current_view().get_selected_ids() results = [] for bid in bids: db.set_series_index(bid, sidx) results.append(db.title(bid, index_is_id=True)) db.refresh_ids(bids) gui.current_view().model().refresh_ids(bids) return 'Done: ' + ', '.join(results) Code:
program: change_series_index(0) You can also use it in an Action Chains formula action. You can't use it in bulk edit search & replace. |
|
![]() |
![]() |
![]() |
#562 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I just put program: columnupdate_seriesindex(0) in the template tester and it worked. The downside is I was testing with a book I hadn't wanted to change to 0. Oh well.
![]() For future reference, can other called python templates update columns directly without the action chain? Additionally: Other than the formulas action, would it work if called in a SFE template mode? That way I could do an if-then. Last edited by ownedbycats; 04-05-2023 at 01:25 PM. |
![]() |
![]() |
![]() |
#563 | |||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,459
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
Quote:
|
|||
![]() |
![]() |
![]() |
#564 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Oh yeah, my brain skipped a few steps "wait, that's why I wasn't using SFE in the first place...". Formulas I'll try that, not as familiar with using them.
|
![]() |
![]() |
![]() |
#565 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I have this template for a composite column used for sorting in one VL/view manager view.
Code:
program: ## This one checks that #kobostatus has a value. If it does, return 'no' if it matches two specific criteria, and 'yes' otherwise. if $#kobostatus then switch_if( '\[(Add|Send) to Device\]' in $#kobostatus, 'No', $#kobostatus=='[Kobo Store]' && !$#kobodate, 'No', 'Yes' ) fi Code:
program: ## This returns an empty if #kobostatus doesn't have a value. Other lines are unaffected. switch_if( !$#kobostatus, '', ## Alternate: $#kobostatus=='', '\[(Add|Send) to Device\]' in $#kobostatus, 'No', $#kobostatus=='[Kobo Store]' && !$#kobodate, 'No', 'Yes' ) Last edited by ownedbycats; 04-09-2023 at 02:59 PM. |
![]() |
![]() |
![]() |
#566 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,459
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#567 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I'll keep the original, then, as it makes a bit more sense to me. Thanks
![]() |
![]() |
![]() |
![]() |
#568 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
For a formula for various book statistics: is there a function similar to round, but rounding to a certain number of decimal points instead of a whole number?
EDIT: format_number works. New question: How do I add a line break? This returns as one long line. ![]() Code:
program: strcat( 'Chapter Count:', $#chaptercount, 'Page Count:', $#pagecount, 'Average Pages per Chapter:', format_number((divide($#pagecount, $#chaptercount)), '{0:5.2f}') ) Last edited by ownedbycats; 04-11-2023 at 09:52 AM. |
![]() |
![]() |
![]() |
#569 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,459
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
|
|
![]() |
![]() |
![]() |
#570 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That works, thanks
![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library Management: various questions not worth their own thread | ownedbycats | Library Management | 227 | Yesterday 05:28 PM |
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates | Boilerplate4U | Development | 13 | 07-07-2020 02:35 AM |
Questions on Kobo [Interfered with another thread topic] | spdavies | Kobo Reader | 8 | 10-12-2014 11:37 AM |
[OLD Thread] Some questions before buying the fire. | darthreader13 | Kindle Fire | 7 | 05-10-2013 09:19 PM |
Thread management questions | meme | Feedback | 6 | 01-31-2011 05:07 PM |