![]() |
#1 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
|
Help: regex for add books
If I use this format for filename:
author - [series] [series_index] title I can use this regex: (?P<author>.+) - \[(?P<series>.+)\] \[(?P<series_index>.+)\] (?P<title>[^_]+) I would prefer: author - [series series_index] title but I don't know how to stop (?P<series>.+) when it gets to numbers, and then include the numbers in series_index EDIT: Never mind. What if the series name is Oceans 11? Will have to stick to current format. What I need is the equivalent to {authors} - [{series} {series_index}] {title} which is used in Save to disk. Last edited by macnab69; 06-15-2013 at 01:35 PM. Reason: Founf answer |
![]() |
![]() |
![]() |
#2 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,751
Karma: 2667650
Join Date: Jul 2012
Device: Android, Nook Simple Touch, Nook Color, ..., Glo
|
Quote:
only problem here is if you do not have a series/series index then you will have empty brackets in your book title when you save to disk. I have something similar but I use a custom column {#myseries} that only fills with the desired text if there is a series (it could even be a hidden column) then I use it in my save to disk and it only appears if needed. You could probably do the same with yours, something like Code:
{authors} - {#myseriesL}{series} {series_index}{#myseriesR} {title} I used 'Column built from other columns' with the following template to create my {#myseries} column: Code:
{series:test(~,)} |
|
![]() |
![]() |
![]() |
#3 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
|
You inspired me to get rid of the empty brackets, so:
If there is no series I want this author - title If there is a series I want this: author - [series series_index] title with a leading 0 if the series_index is less than 10. So I use this for the save to disk template {authors} - {series:| [| } {series_index:0>2s| |]} {title} Works perfectly for both cases. |
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,751
Karma: 2667650
Join Date: Jul 2012
Device: Android, Nook Simple Touch, Nook Color, ..., Glo
|
{series:| [| } , huh
I was looking for a regex way for you to do what you wanted, but looks like you found Cool |
![]() |
![]() |
![]() |
#5 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
|
Looked up template in the calibre manual. It discusses exactly what I was looking for.
![]() |
![]() |
![]() |
![]() |
Tags |
add books, regex |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Name for series index in regex for add books | macnab69 | Library Management | 0 | 06-15-2013 12:53 PM |
My RegEx works in Test but not for Add Books | kanigetts | Library Management | 11 | 09-18-2012 02:59 AM |
Want RegEx to add books to Calibre | huon | Library Management | 0 | 02-02-2012 12:52 AM |
Add Books - Regex Help Please | nynaevelan | Calibre | 2 | 08-16-2011 01:30 PM |
understandng the sample add books regex | cybmole | Library Management | 11 | 03-02-2011 06:08 AM |