I'm desperately looking for a regex which would automatically search in my eBooks' titles the string "2012" (for example) and put it in my pubdate field. And, once this is done, I would also like it to replace some other fields like this, but the pubdate is the hardest for me.
Let me show you an example :
The pdf file is : TitleOfTheSerie Volume1 Number1 (out of 3) (2012)
I would like to use the Search&Replace function of Calibre to extract those informations and put them in the correct place.
So : 2012 -> pubdate (I'll use january everytime)
TitleOftheSerie -> Serie
Number -> Serie[X]
Originally Posted by HarryT
Try using a search string of:
and a replace string of:
ie, with parentheses around the "search string" for the numbers.
So this seems very useful to me! I already adapted it to this :
Search in : title
For : ([0-2][0-9][0-9][0-9])
And replace it by : janv. \1
In : pubdate
But I get an error :
unknown string format
calibre, version 0.9.11
ERREUR : Echec: unknown string format
Traceback (most recent call last):
File "/usr/lib/calibre/calibre/gui2/dialogs/metadata_bulk.py", line 125, in do_one_safe
File "/usr/lib/calibre/calibre/gui2/dialogs/metadata_bulk.py", line 290, in do_one
File "/usr/lib/calibre/calibre/gui2/dialogs/metadata_bulk.py", line 851, in do_search_replace
setter(id, val, notify=False, commit=False)
File "/usr/lib/calibre/calibre/library/database2.py", line 2613, in set_pubdate
dt = parse_only_date(dt)
File "/usr/lib/calibre/calibre/utils/date.py", line 94, in parse_only_date
ans = parse_date(raw, default=default, assume_utc=assume_utc)
File "/usr/lib/calibre/calibre/utils/date.py", line 80, in parse_date
dt = parse(date_string, default=default, dayfirst=parse_date_day_first)
File "/usr/lib/python2.7/dist-packages/dateutil/parser.py", line 697, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File "/usr/lib/python2.7/dist-packages/dateutil/parser.py", line 303, in parse
raise ValueError, "unknown string format"
ValueError: unknown string format
I also tried many combinations such as :
01 janv. \1
but none of them had worked
Could you help me?
Thanks in advance,