|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Member
![]() 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. |
|
|
|
|
|
#2 |
|
Member
![]() 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. |
|
|
|
| Advert | |
|
|
|
|
#3 | |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
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. |
|
|
|
|
|
|
#4 | |
|
Member
![]() Posts: 19
Karma: 10
Join Date: Oct 2012
Device: Kobo Clara
|
Quote:
(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. |
|
|
|
|
|
|
#5 |
|
Member
![]() 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?
|
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Member
![]() 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)})}
Last edited by robowolf; Today at 12:18 PM. |
|
|
|
|
|
#7 |
|
Leftutti
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
|
|
|
|
|
#8 | |
|
Member
![]() 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,&)}
Code:
{author_sort:contains(\&,{author_sort:sublist(0,1,&)},{author_sort})}
Quote:
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. |
|
|
|
|
|
|
#9 |
|
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 |
|
|
|
![]() |
|
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 |