|
|
#1 |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Feb 2023
Device: iPhone
|
I was trying to organize my library and wanted a column for book subtitles (there isn't one built in already). How do I use custom template functions in the custom column (built from other columns) to take everything after the last colon and space as the output? I have tried several different things to no avail.
For example, the title column "Atomic Habits: Tiny Changes, Remarkable Results: An Easy & Proven Way to Build Good Habits & Break Bad Ones" would feed into a separate subtitle column that just says "An Easy & Proven Way to Build Good Habits & Break Bad Ones". Thanks in advance for any help! |
|
|
|
|
|
#2 |
|
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,364
Karma: 79528341
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
Any reason to not just use a regular text column for this?
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,270
Karma: 61916422
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
I Move that (sub title) to a custom Text column using the Metadata Editors (bulk mode) Search and Replace.
(.+?)\:(.+?) Basically a Copy, \2 to #subtitle followed by a delete (from Title) \1 to Title AFAIK this does not hurt Get Metadata searches |
|
|
|
|
|
#4 |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Feb 2023
Device: iPhone
|
Only that I didn't want to have to copy and paste manually, but I didn't think of using the search & replace as suggested by theducks.
Last edited by WillE; 02-24-2023 at 10:27 AM. Reason: Typed the wrong name |
|
|
|
|
|
#5 | |
|
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Feb 2023
Device: iPhone
|
Quote:
This worked for me! I don't know how to delete the subtitle out of the title column though (without doing it manually). |
|
|
|
|
| Advert | |
|
|
|
|
#6 | |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,270
Karma: 61916422
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
What that does is drops the : and second capture piece |
|
|
|
|
|
|
#7 |
|
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 295
Karma: 2534928
Join Date: Nov 2022
Location: Canada
Device: Kobo Aura 2
|
I think this template might do what you're after, if you're still interested in a template-based solution:
Code:
{title:'sublist($,-1,0,': ')'}
Code:
{title:'sublist($,0,-1,': ')'}
After testing, the Title one will turn up empty if a title has no colon. Probably fine for the subtitle, but not the title. So I offer this refinement: Code:
{title:'ifempty(sublist($,0, -1,': '), $)'}
Last edited by isarl; 02-24-2023 at 03:28 PM. Reason: OP asked for LAST colon – I should have used -1, not +1, as the sublist index. Fixed. |
|
|
|
|
|
#8 |
|
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 295
Karma: 2534928
Join Date: Nov 2022
Location: Canada
Device: Kobo Aura 2
|
(A word of caution – in my own library, some books use a format of Title—Subtitle, or even Title, or Subtitle.
Good luck!)
|
|
|
|
|
|
#9 |
|
Leftutti
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 550
Karma: 1717097
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
|
I once got this from chaley for the KTE Driver and subtitles after colon. Maybe this will help someone.
Code:
program: v_1 = ''; list_split($title, ':', 'v'); # Enter v_0 for the text before the colon, v_1 for the text after the colon # This doesn't work if the title or subtitle part contains extra colons # v_1 is empty if there are no colons at all v_1 |
|
|
|
|
|
#10 | ||
|
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 295
Karma: 2534928
Join Date: Nov 2022
Location: Canada
Device: Kobo Aura 2
|
Quote:
Quote:
|
||
|
|
|
|
|
#11 |
|
Leftutti
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 550
Karma: 1717097
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
|
Ok. I missed that he had maybe more than one colon.
|
|
|
|
|
|
#12 |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,270
Karma: 61916422
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
|
|
|
|
|
#13 |
|
Leftutti
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 550
Karma: 1717097
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
|
I looked at his example again.
In "Atomic Habits: Tiny Changes, Remarkable Results: An Easy & Proven Way to Build Good Habits & Break Bad Ones" I would replace the first colon with an emdash, as I think it belongs even more to the title. This way you can avoid several colons, which in my eyes are also not nice |
|
|
|
|
|
#14 | |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,270
Karma: 61916422
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Besides, that would be a horrific filename and even worse when file system shorten rules kick in
|
|
|
|
|
![]() |
| Tags |
| expressions, templates |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Template: saving template tester when restarting Calibre | ownedbycats | Library Management | 14 | 03-29-2021 06:57 PM |
| Template: Converting a search & replace into a template | ownedbycats | Library Management | 11 | 03-26-2021 05:32 AM |
| Using built-in template functions in a custom template function | ilovejedd | Library Management | 4 | 01-28-2018 01:20 PM |
| Book SubTitle? | taraboom11 | Library Management | 1 | 03-01-2011 09:48 PM |