08-06-2013, 03:55 PM | #1 |
Connoisseur
Posts: 54
Karma: 6910
Join Date: Jul 2013
Device: Kindle Touch
|
Regexp for author name: No switching and no comma, how?
Hi guys I'm trying to find a regexp for the following
author names - [series name 0x] - title. file ext Any regexp I use switches the author names. Example: Greg Cox - [Underworld 01] - Underworld (v1.6) (mobi).mobi will be: Author: Cox Greg Series: [ Underworld Series Index: 01 Title: Underworld (v1.6) Questions: 1. How to NOT switch first and second name 2. How to remove [ from series 3. How to remove info in brackets (v1.6) Expressions tried: (?P<author>((?!\s-\s).)*)\s-(?:\s((?P<series>.+) (?P<series_index>\d+)((?!\s-\s).)*)\s-)?\s(?P<title>.*) (?P<author>[^_-]+) -?\s*(?P<series>[^_0-9-]*)(?P<series_index>[0-9]*)\s*-\s*(?P<title>[^_].+) ? Variations for author taken from other expressions as: (?P<author>[^_]+) (?P<author>.+) (?P<author>((?!\s-\s).)*)\s and others.... Thank you |
08-06-2013, 05:01 PM | #2 |
Handy Elephant
Posts: 1,736
Karma: 26785668
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Thinkpad E595, Ubuntu Mate, Huawei Mediapad 5, Bouye Likebook Plus
|
This should work:
(?P<author>.+)\s-\s\[(?P<series>.+)\s(?P<series_index>\d+)\]\s-\s(?P<title>.+)\s(\(.+\)\s)+ But I usually just add the whole filename to title, and afterwards use Edit metadata in bulk to do some search and replace to populate the other fields and trim unwanted stuff.. I find that to be much faster and safer than trying to adjust the regexp to read metadata from the filename, when it gets complicated. You can even squirrel away the whole original filename to a custom field for future use. The author first and last name most likely does not switch due to this regexp. But there is a checkbox in the dialog, where you set the regexp, for switching firstname and lastname. Make sure it is unchecked. Otherwise you could have a tweak active that cause this. Try setting the defaults for all tweaks regarding author and author_sort to see if you can find what the problem is. http://manual.calibre-ebook.com/customize.html#tweaks Last edited by Adoby; 08-06-2013 at 05:08 PM. |
Advert | |
|
08-06-2013, 05:05 PM | #3 | |
Connoisseur
Posts: 54
Karma: 6910
Join Date: Jul 2013
Device: Kindle Touch
|
Thanks Abody,
I like how it works with the series info. I don't mind it being into the titles field but the author name is still switched. I would like if I don't have to edit after adding of the books. Gonna check the link now ... Quote:
Edit 1: I think I found it. I haven't been in the tweaks before. The author sort name was comma, which uses copy when there is comma and otherwise inverts the name. Changed it to copy. Gonna see now it that works Edit 2: No, that is for author name sort. Not for the name Last edited by crdf; 08-06-2013 at 05:13 PM. |
|
08-06-2013, 05:06 PM | #4 |
Connoisseur
Posts: 54
Karma: 6910
Join Date: Jul 2013
Device: Kindle Touch
|
Ops. Post 4 for deleting
|
08-06-2013, 05:13 PM | #5 |
Handy Elephant
Posts: 1,736
Karma: 26785668
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Thinkpad E595, Ubuntu Mate, Huawei Mediapad 5, Bouye Likebook Plus
|
|
Advert | |
|
08-06-2013, 05:22 PM | #6 |
Connoisseur
Posts: 54
Karma: 6910
Join Date: Jul 2013
Device: Kindle Touch
|
|
08-06-2013, 05:27 PM | #7 |
Handy Elephant
Posts: 1,736
Karma: 26785668
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Thinkpad E595, Ubuntu Mate, Huawei Mediapad 5, Bouye Likebook Plus
|
Easy to miss, I don't think I've seen that checkbox ever before today...
|
08-06-2013, 05:37 PM | #8 | |
Well trained by Cats
Posts: 29,800
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
I always wondered on how it functioned: My (default) Author view is Fn Ln But sometimes a book contains Ln, Fn Does it ALWAYS flip or does it follow the Tweak setting and conditionally invoke itself when needed? |
|
08-06-2013, 05:45 PM | #9 | |
Connoisseur
Posts: 54
Karma: 6910
Join Date: Jul 2013
Device: Kindle Touch
|
I'm sure I've seen it before but I'm lacking a lot of sleep.
I found the regexp to remove the [ bracket from the series info in another topic: /post 09-24-2010, 04:29 AM/ Credit to: megachirops Code:
(?P<author>((?!\s-\s).)+)\s-\s(?:(?:\[\s*)?(?P<series>.+)\s(?P<series_index>\d+)(?:\s*\])?\s-\s)?(?P<title>[^(]+)(?:\(.*\))? The Ducks when there is no comma it was flipping the name from Greg Cox to Cox Greg. The Tweak setting is about the sort name and it did not affect the author name in the title and the importing of the name, so I guess that is why it is a separate setting. Ok, so I changed the tweak for author_sort_name to 'copy' and unchecked the swap author's names. Looking at the metadata of a book the sort name is swapped with a coma. Quote:
I'm really no sure if that answers your question. Edit: If author is Cox, Greg it does not invert and Author sort is: Austen, Jane Last edited by crdf; 08-06-2013 at 06:05 PM. Reason: More Info |
|
Tags |
author name order, regexp, regexp author |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
_ before but now a comma | pghaworth | Calibre | 7 | 05-09-2013 09:22 PM |
Switching of title and author | Lotus Eater | Calibre | 1 | 02-18-2011 02:23 AM |
Switching author name from comma separated to first last | kbaggs | Library Management | 1 | 01-30-2011 03:36 PM |
NCX file issue with comma's | Matt.Geiger | Kindle Formats | 1 | 12-21-2010 10:28 AM |
Using a comma in the Tags field | Agama | Calibre | 1 | 11-22-2010 06:10 PM |