Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 02-23-2023, 09:46 PM   #1
WillE
Junior Member
WillE began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Feb 2023
Device: iPhone
Exclamation Subtitle Template

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!
WillE is offline   Reply With Quote
Old 02-23-2023, 10:38 PM   #2
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,991
Karma: 75337983
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?
ownedbycats is offline   Reply With Quote
Advert
Old 02-24-2023, 06:55 AM   #3
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,072
Karma: 60358908
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
theducks is online now   Reply With Quote
Old 02-24-2023, 09:26 AM   #4
WillE
Junior Member
WillE began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Feb 2023
Device: iPhone
Quote:
Originally Posted by ownedbycats View Post
Any reason to not just use a regular text column for this?
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 09:27 AM. Reason: Typed the wrong name
WillE is offline   Reply With Quote
Old 02-24-2023, 09:33 AM   #5
WillE
Junior Member
WillE began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Feb 2023
Device: iPhone
Quote:
Originally Posted by theducks View Post
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
Hopefully, this doesn't appear twice. I thought I hit submit, but I don't see it.
This worked for me! I don't know how to delete the subtitle out of the title column though (without doing it manually).
WillE is offline   Reply With Quote
Advert
Old 02-24-2023, 11:47 AM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,072
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:
Originally Posted by WillE View Post
Hopefully, this doesn't appear twice. I thought I hit submit, but I don't see it.
This worked for me! I don't know how to delete the subtitle out of the title column though (without doing it manually).
The second Replace: \1 using the same search as before, but this time the destination is Title
What that does is drops the : and second capture piece
theducks is online now   Reply With Quote
Old 02-24-2023, 12:12 PM   #7
isarl
Addict
isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.
 
Posts: 287
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,': ')'}
If you wanted another template for the title without the subtitle, you could use:

Code:
{title:'sublist($,0,-1,': ')'}
I included the space following the colon, but I don't think it's actually needed. I'm fairly sure that the sublist() function will trim each each entry after splitting them. Removing the space may result in a more permissive template if it's at all possible that some of your books might have a Title:Subtitle with no separating space.

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 02:28 PM. Reason: OP asked for LAST colon – I should have used -1, not +1, as the sublist index. Fixed.
isarl is offline   Reply With Quote
Old 02-24-2023, 12:17 PM   #8
isarl
Addict
isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.
 
Posts: 287
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!)
isarl is offline   Reply With Quote
Old 02-24-2023, 02:13 PM   #9
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 549
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
https://www.mobileread.com/forums/sh...postcount=2828
Wiggo is offline   Reply With Quote
Old 02-24-2023, 02:31 PM   #10
isarl
Addict
isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.
 
Posts: 287
Karma: 2534928
Join Date: Nov 2022
Location: Canada
Device: Kobo Aura 2
Quote:
Originally Posted by Wiggo View Post
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
https://www.mobileread.com/forums/sh...postcount=2828
This template will split on EVERY colon and return the second part, which might not be the last part like OP was seeking. From the template docs for list_split:

Quote:
split(‘one:two:foo’, ‘:’, ‘var’) is equivalent to var_0 = ‘one’; var_1 = ‘two’; var_2 = ‘foo’
isarl is offline   Reply With Quote
Old 02-24-2023, 03:58 PM   #11
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 549
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.
Wiggo is offline   Reply With Quote
Old 02-24-2023, 06:01 PM   #12
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,072
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:
Originally Posted by Wiggo View Post
Ok. I missed that he had maybe more than one colon.
I missed that also
theducks is online now   Reply With Quote
Old 02-25-2023, 04:15 AM   #13
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 549
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
Wiggo is offline   Reply With Quote
Old 02-25-2023, 07:00 AM   #14
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,072
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:
Originally Posted by Wiggo View Post
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
↑ ↑ ↑ ✔

Besides, that would be a horrific filename and even worse when file system shorten rules kick in
theducks is online now   Reply With Quote
Reply

Tags
expressions, templates


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Template: saving template tester when restarting Calibre ownedbycats Library Management 14 03-29-2021 05:57 PM
Template: Converting a search & replace into a template ownedbycats Library Management 11 03-26-2021 04:32 AM
Using built-in template functions in a custom template function ilovejedd Library Management 4 01-28-2018 12:20 PM
Book SubTitle? taraboom11 Library Management 1 03-01-2011 08:48 PM


All times are GMT -4. The time now is 09:03 PM.


MobileRead.com is a privately owned, operated and funded community.