07-11-2012, 04:50 PM | #1 |
Zealot
Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
|
Calibre authors LN, FN to FN LN "swap_around_comma"
In a sub-library I have a large number of books where the "authors" field is the same as "author_sort" (i.e. LN, FN) and I was trying to figure out how to do a bulk metadata edit in order to reformat all the "authors" names to FN LN for overall library consistency.
The link "http://manual.calibre-ebook.com/template_lang.html" refers to the function "swap_around_comma(val)" but I couldn't figure out how to use it in the context of a bulk edit of the metadata. I tried two approaches: a) first tried setting up a custom user-defined column to get a re-formatted author name by using the above function in the template definition for the column when it is created (as suggested by the general approach of "using templates in custom columns" at the link "http://manual.calibre-ebook.com/template_lang.html"), and b) also tried using "swap_around_comma" as a type of general expression within the context of a "search and replace" bulk metadata edit copying the authors column to a general user-defined text column. In both cases above I was unable to figure out the correct syntax, and tried things like {authors:swap_around_comma()} and tried {swap_around_comma(authors)} and {swap_around_comma(LN,FN)}. Has anyone seen any further documentation on this function, or can provide the syntax for using this function in the context of either of the above approaches, or some alternative bulk edit approach? Thanks ...Rob |
07-12-2012, 02:28 AM | #2 |
Wizard
Posts: 1,065
Karma: 858115
Join Date: Jan 2011
Device: Kobo Clara, Kindle Paperwhite 10
|
Welcome to Mobile Read. Try the third-party plugin Quality Check, available through Preferences/Plugins. Click the Get New Plugins button on the bottom in Prefs/Plugins and look at uninstalled plugins. Install Quality Check.
Search for all books with the comma in authors. In Quick Search box at top type: Code:
author:, 1. Use Quality Check, Fix menu, Swap Author command. Or (more complicated): 2. Use Edit Metadata in Bulk, Search and Replace Tab, regular expression mode to switch elements around the comma. Search field: authors Search for: Code:
(.+), (.*) Code:
\2 \1 Note: that will mess up any authors with ", Jr" after last name, but then you can fix those after searching for "author:Jr". Last edited by unboggling; 07-12-2012 at 05:21 AM. Reason: detail re installing plugin |
Advert | |
|
07-12-2012, 05:28 AM | #3 | |
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
To reinforce unboggling's comment: templates operate on all the authors at once. Using swap_around_comma() on a book with multiple authors such as "Blogs, Joe & Sneeze, Sam" will produce "Joe & Sneeze, Sam Blogs. The bulk metadata method overcomes the multiple author problem because it processes the authors one at a time. |
|
07-12-2012, 05:36 AM | #4 | |
Zealot
Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
|
Quote:
I tried the bulk metadata edit approach using the search and replace parameters you suggested, and it worked great! Per your caution on potential exceptions, the only additional steps that I took were: a) first located and adjusted all authors names that contained more than one comma (I didn't know how to search for two commas in the Calibre search and so used a separate program outside of Calibre to list out all the author folder names shown in Windows Explorer and then used a character string test within Excel), b) copied the metadata edit results to a test user-defined column prior to copying the results into the "author" field. Thank you unboggling ! |
|
07-12-2012, 06:13 AM | #5 | |
Zealot
Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
|
syntax for using swap_around_comma(val) ?
Quote:
Thank you for confirming that you were able to get the template "swap_around_comma(val)" to work in the context of both approaches a) and b) as described above. (The issue with multiple authors can be resolved okay in different ways I guess.) I was curious how you got swap_around_comma(val) to work, in terms of the specific use and syntax for each of the two approaches. I had mentioned several examples for the syntax that I tried using but those did not seem to work. The questions I was struggling with include: i) does swap_around_comma(val) need to be enclosed in {}; ii) is "val" a general parameter to be replaced by something else; iii) in bulk edit search and replace does it go in the "search for:" section; iv) is the syntax different for the bulk edit approach compared to the template syntax when setting up a user-defined custom column with column type "Column build from other columns". v) maybe seeing specific examples is the easiest way to see how it works? I have been using Calibre for a relatively short period of time but it is really impressive open source software that particularly Kovid Goyal, and all of you, have helped to create. |
|
Advert | |
|
07-12-2012, 06:35 AM | #6 | |||||
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
Quote:
The search expression searches the result of evaluating the template. Quote:
Quote:
|
|||||
07-12-2012, 07:12 AM | #7 | ||
Zealot
Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
|
Quote:
Thanks again for your help on this, and the other alternative provided by unboggling ! The only lingering question related to this process is whether there is a search technique within Calibre to identify author names that contain two commas, so that complication can be more simply resolved prior to running the bulk edit? |
||
07-12-2012, 07:16 AM | #8 |
Wizard
Posts: 1,065
Karma: 858115
Join Date: Jan 2011
Device: Kobo Clara, Kindle Paperwhite 10
|
Ah, I like that question, was wondering about that myself earlier.
|
07-12-2012, 07:23 AM | #9 |
Calibre Plugins Developer
Posts: 4,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
This would work:
Code:
authors:"~.*,.*," |
07-12-2012, 07:33 AM | #10 |
Zealot
Posts: 108
Karma: 810
Join Date: Jul 2012
Device: Kobo
|
|
07-12-2012, 07:50 AM | #11 |
Wizard
Posts: 1,065
Karma: 858115
Join Date: Jan 2011
Device: Kobo Clara, Kindle Paperwhite 10
|
|
07-12-2012, 08:04 AM | #12 |
Calibre Plugins Developer
Posts: 4,636
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
In this particular case it tells calibre that what follows is to be treated as a regular expression.
|
07-12-2012, 08:07 AM | #13 |
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Do note that this regexp will find books with any author having a name containing more than one comma. It will not find books with multiple authors, each containing a comma. For example, it will find "Blogs, PhD, Joe" but it will not find "Blogs, Joe & Sneeze, Sam". Depending on what you are doing, this distinction will matter.
It tells search that what follows is a regular expression. It is similar to the "=" that tells search that what follows must be a complete match, and the period that tells search that what follows is a hierarchical match. |
07-12-2012, 08:53 AM | #14 | ||
Wizard
Posts: 1,065
Karma: 858115
Join Date: Jan 2011
Device: Kobo Clara, Kindle Paperwhite 10
|
Quote:
Quote:
Last edited by unboggling; 07-12-2012 at 08:59 AM. |
||
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
PRS-T1 Sony "Collections" vs Calibre "Series" | ted13b | Sony Reader | 3 | 02-20-2012 09:46 AM |
Getting calibre to detect "Prologue" and "Epilogue" for TOC | sherman | Calibre | 2 | 09-20-2010 02:21 AM |
UK Daily Telegraph "Ebooks will make authors soulless, just like their product" | Sparrow | News | 46 | 09-18-2009 06:55 PM |