08-01-2011, 11:33 AM | #1 |
Junior Member
Posts: 1
Karma: 10
Join Date: Aug 2011
Device: none
|
regex help please
i just discovered calibre and now i try to work into it, but regular expressions are a obstacle i can't break through until now. i have no clue about programming whatsoever and after hours of trying i give up. i have a huge collection of mainly scientific books, the filenames are in this format: <author> <year> <tiltle>, e.g. "tabachnick 2007 using multivariate statistics.pdf". what i want to do is to extract metadata from filenames. i used this regex: (?P<author>[^_]+) (?P<published>\d\d\d\d) (?P<title>.+). it correctly extracts author and title , but in the published-field it extracts 2007-07-31 any ideas what is wrong with the regex? thanks in advance!
|
08-01-2011, 11:57 AM | #2 |
Grand Sorcerer
Posts: 6,206
Karma: 16228558
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
I stand to be corrected but I'm not sure anything is wrong. The 'published' field is expecting a valid date. Your filename only contains the 'year' portion so Calibre has created the 'month' and 'day' portions as today's month and day.
|
Advert | |
|
08-01-2011, 11:27 PM | #3 |
US Navy, Retired
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
If you change the Tweak to display the year only, you would only see 2007. It works for me, YMMV.
# Control how dates are displayed gui_pubdate_display_format = 'yyyy' |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Regex | Faster | Sigil | 2 | 04-24-2011 09:08 PM |
regex replace??? | schuster | Conversion | 14 | 01-29-2011 09:02 AM |
What a regex is | Worldwalker | Calibre | 20 | 05-10-2010 05:51 AM |
Help with a regex | A.T.E. | Calibre | 1 | 04-05-2010 07:50 AM |
Regex help... | Bobthebass | Workshop | 6 | 04-26-2009 03:54 PM |