|02-28-2010, 10:49 AM||#1|
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Optional characters in Save Template for Adding Books
My original books are all in a standard name format of:
Lastname, Firstname - Series ## - Title.ext
Of course, some books have no Series, and they are in this format:
Lastname, Firstname - Title.ext
I have a regex in the Adding Books Preferences page that always splits the name correctly, regardless of which of the two forms are drag/dropped into Calibre. The regex relies on the space-hyphen-space to do the splitting.
I'd like to be able to export from Calibre with Save Books in a way that would reproduce the same name that the book had when it was imported. That's pretty easy if all books were in one form, but the problem arises when a book does not have a series. If I use the series and series_number in the Save Template, I need to separate it by the space-hyphen-space, but if there's no series, that space-hyphen-space separator always appears in the filename. The result is that I get an extra space-hyphen-space in the filename when there's no series.
My question: Is there any way to make the space-hyphen-space separator optionally dependent on the presence or absence of the series so that the output name is in format 1 when there is a series, and in format 2 when there isn't? Is there some trick to this that I've missed? Thanks!
|02-28-2010, 12:52 PM||#2|
creator of calibre
Join Date: Oct 2006
Location: Mumbai, India
the templates use pythons format strings, as far as I recall there's no way to do conditionals in those.
|Thread Tools||Search this Thread|
|Thread||Thread Starter||Forum||Replies||Last Post|
|Changing "Save Template" not working?||monkbythesea||Calibre||10||08-04-2010 03:30 AM|
|Using Custom Metadata in Save Template||EJvdH||Calibre||1||07-02-2010 06:06 AM|
|save to disk template||speakingtohe||Calibre||9||05-29-2010 06:02 AM|
|Save template for title metadata?||Bob Butler||Calibre||10||03-15-2010 01:05 PM|
|Garbage characters in gutenburg books||ylsul||Sony Reader||3||04-25-2007 02:09 PM|