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 06-29-2026, 07:00 PM   #1
robowolf
Member
robowolf began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Oct 2012
Device: Kobo Clara
Authors in the file name: only surname + "et al" replacing additional authors

I have searched both mobileread and r/Calibre, but I haven't found this.

When I send books to my device, I would like the file name to follow a template of: author's surname / title. So the example book of "How to Read" by Alex Brown would be: Brown/How To Read.

For multiple authors, I would like the file name to shorten to first surname + "et al". So if "Write Today" was written by Alice Johnson and David Egg, it would be: Johnson et al/Write Today. I only want "et al" to append to multiple authors, of course - I don't want Brown et al/How to Read when there's only one author.

To sum up, what I am trying to do is:
1. Isolate the surname only from the author(s).
2. For multiple authors, shorten to the first listed author and add "et al" to the end.

I assume I am not the only person who wanted to accomplish either of these, but I am struggling to find any threads or posts about it.
robowolf is offline   Reply With Quote
Old 06-29-2026, 07:01 PM   #2
robowolf
Member
robowolf began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Oct 2012
Device: Kobo Clara
My progress so far:

I've managed to find a template to shorten all author names to just their surnames (based on this post by chaley, which is inspired by brewjono), but I'm stymied at how to turn multiple authors into "Johnson et al".
Code:
{author_sort:re(\, (.).*?( &|$),)}

Last edited by robowolf; Today at 12:18 PM.
robowolf is offline   Reply With Quote
Advert
Old 06-30-2026, 06:01 AM   #3
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 84,032
Karma: 153695583
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by robowolf View Post
I have searched both mobileread and r/Calibre, but I haven't found this.

When I send books to my device, I would like the file name to follow a template of: author's surname / title. So the example book of "How to Read" by Alex Brown would be: Brown/How To Read.
This is a really bad idea. You create all kinds of directories. If you delete your eBooks from the Kobo, you'll eventually end up with a lot of empty directories.

What I do is I have a directory called books and I put all of my eBooks on my Kobo in there.

Kobo doesn't do directories. It does collections and series.
JSWolf is offline   Reply With Quote
Old 06-30-2026, 08:54 PM   #4
robowolf
Member
robowolf began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Oct 2012
Device: Kobo Clara
Quote:
Originally Posted by JSWolf View Post
This is a really bad idea. You create all kinds of directories. If you delete your eBooks from the Kobo, you'll eventually end up with a lot of empty directories.

What I do is I have a directory called books and I put all of my eBooks on my Kobo in there.

Kobo doesn't do directories. It does collections and series.
Of course it still goes into an overarching folder like "books" - I'm referring to the save template available in Preferences > Send to device > Save template, where it currently has "{author_sort}/{title}".

(Also, this actually wouldn't be to Kobo (I realize that is what it says in my profile), this would be to a new device which I am currently in the process of finding.)

If it's easier, I am currently testing my work in a custom column; even if this can't work as a save template, I now want to know how I could achieve this with scripting, since it's made me curious.
robowolf is offline   Reply With Quote
Old 07-01-2026, 08:15 PM   #5
robowolf
Member
robowolf began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Oct 2012
Device: Kobo Clara
To simplify all of this: I want to make a custom column to show either the solo author's surname or shorten multiple authors to first surname + "et al". How can I achieve this?
robowolf is offline   Reply With Quote
Advert
Old 07-02-2026, 09:32 AM   #6
robowolf
Member
robowolf began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Oct 2012
Device: Kobo Clara
I think I did it! I'm very new to regex and python in general, so if someone could look at this and see if there are obvious errors or redundancies I can fix, I would appreciate it.

Code:
{author_sort:contains(\&,{author_sort:re(\, (.).*+( &|$), et al)},{author_sort:re(\, (.).*?( &|$),\2)})}
I am very grateful to the "Edit Template" option in the Custom Columns, because it let me play around with code and see how it affected selected books.

Last edited by robowolf; Today at 12:18 PM.
robowolf is offline   Reply With Quote
Old 07-02-2026, 11:04 AM   #7
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: 643
Karma: 3671119
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
I did heavy regexing with ClaudeAI recently and it worked very well. A few minor hiccups and a bit of grumbling, but it all worked out in the end.
Wiggo is offline   Reply With Quote
Old Today, 12:16 PM   #8
robowolf
Member
robowolf began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Oct 2012
Device: Kobo Clara
Now that I got that code to work, I am curious what else I can do (again, I am doing this in a custom column to experiment with code). I want to see if I can get the code to do "Last, First[, et al]". I assume I can use the same pattern of contains + the code I want, but I run into a problem.

This code (user DNSB has referenced it before) will always return the first author as listed:
Code:
{author_sort:sublist(0,1,&)}
But when I insert it into my contains code from before, I run into a problem.
Code:
{author_sort:contains(\&,{author_sort:sublist(0,1,&)},{author_sort})}
The message I get for any author_sort field that contains a non-special characters regardless of solo or multiple authors is:
Quote:
EXCEPTION: Incorrect number of arguments for function contains
Why does the code now say there is an incorrect number of arguments for the function? It worked with other code before. I cannot see that I am missing anything. Is the sublist function unable to be put in a contains function (but the re function is okay)?
If all authors are mononyms without special characters (excluding ampersand (&)), then there is no problem. There is no problem if the author names include non-English characters (I tested with Latin, Ukrainian, Chinese (mainland), and Vietnamese) without special author_sort (that is, author_sort matched the author field and had no commas, etc). The problem seems to be introducing special characters like commas, parentheses, etc.

This breaks for the following author_sort:
LastA, FirstA
LastA, FirstA & LastB, FirstB
LastA, FirstA & monoA
pseudA (monoB)

This works fine for the following author_sort:
monoA
monoA & monoB

Last edited by robowolf; Today at 01:00 PM.
robowolf is offline   Reply With Quote
Old Today, 03:10 PM   #9
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,860
Karma: 64181416
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
This is a relational database. each Author is defined once and assigned a 'index' (that is why it is easy to fix a spelling or case using the tag browser. You fix the definition, not the books that use it.

& is a logical separator in the Authors field and does not exist in the author table, so it can not be a find trigger.

The display is assembled and the & inserted/restored
There are 'n' entries in the underlying books_authors_lnk table for that book . One for each author
theducks is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I swap authors to first name surname instead of surname,first name madeirabhoy Library Management 2 07-31-2020 07:45 PM
Forma How do u deal with authors who are "Jr"? (Kobo ignores Calibre's "Author Sort" field) droopy Kobo Reader 0 09-06-2019 05:51 PM
Folder sorting: mixed "name surname" and "surname, name"! shuusaku Library Management 2 10-18-2013 01:43 AM
Can I generate Additional Authors column which shares Authors data? GeekyGal Library Management 4 10-04-2011 09:17 PM
Authors surname first ? geordiejohn Calibre 5 12-09-2010 11:33 AM


All times are GMT -4. The time now is 07:05 PM.


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