10-24-2014, 06:19 AM | #1 |
Junior Member
Posts: 1
Karma: 10
Join Date: Oct 2014
Device: kindle touch
|
Please help with regular expressions when adding books
I have a number of books with filenames in this style:
austen-jane-1775-1817_mansfield-park.pdf The 1775-1817 bit is when the author was alive, and I don't care if that gets left out of the metadata entirely. I'm also not concerned with capitalising the author and book title correctly. Others in this style: london_jack-the_call_of_the_wild.pdf Others in this style: Doyle, Arthur Conan - Adventures of Sherlock Holmes, The.txt Others in this style: Grimms Fairy Tales - Adventures of Aladdin.txt Others in this style: Lewis, C.S - The Chronicles of Narnia 2 - The Lion, the Witch and the Wardrobe.txt Firstly, I would be grateful for advice on regular expressions for adding these. Secondly, am I correct in thinking that there's no regular expression which could import all of these correctly at the same time, and thus I will need to import each file-naming-convention separately? |
10-25-2014, 04:25 AM | #2 | ||
enturbulated
Posts: 30
Karma: 130494
Join Date: May 2007
Device: Kobo Aura HD
|
I can't tell you if there is one regex that will do all your filenames.
I know far too little. If you want to start adding some anyway then ... Quote:
This regex from kiwidude works on both of the above two filenames. Code:
^(?P<author>((?!\s-\s).)+)\s-\s(?:(?:\[\s*)?(?P<series>.+)\s(?P<series_index>[\d\.]+)(?:\s*\])?\s-\s)?(?P<title>[^(]+)(?:\(.*\))? Bloggs, Joe - My title Bloggs, Joe - Some Series 1 - My title.txt Bloggs, Joe - Some Series 1.5 - My title.txt Bloggs, Joe - Some Series 1.5 - My title with sub-title hyphen.txt Quote:
Series - Title If so the regex below works when I test it. (?P<series>[^_]*) - (?P<title>.+) |
||
Advert | |
|
Tags |
regex, regular expressions |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A new user's collection of Regular Expressions (regex) for 'Add books > Control the a | kite | Library Management | 2 | 11-04-2015 06:51 AM |
Adding books, Regular expression help please | Shadewing | Library Management | 13 | 04-04-2012 05:31 AM |
Could use a bit of help with regular expressions to edit books on conversion | Flammy | Conversion | 3 | 12-29-2011 10:29 AM |
Adding books - need help with regular expressions | tweebee | Library Management | 10 | 08-05-2011 08:58 PM |
Custom Regular Expressions for adding book information | bigbot3 | Calibre | 1 | 12-25-2010 06:28 PM |