![]() |
#1 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 691
Karma: 3026110
Join Date: Dec 2008
Location: Lancashire, U.K.
Device: BeBook 1, BeBook Pure, Kobo Glo, (and HD),Energy Sistem EReader Pro +
|
Apostrophe in Title/Filename
I have hit a problem using a new Reader - It has issues with files which contain an apostrophe in their filename.
When I transfer a file it uses {title_sort} in generating the filename and in some cases this results in a filename which contains an apostrophe. While I can avoid this by using Titles that don't contain an apostrophe it is a messy approach as all my other readers are happy with this (I think FWICR that in the case of Kepubs this is handled by the extended Kepub driver). Is there any way to "sanitise" the title when using an Android device driver (or preferably any driver) when generating the filename so that for instance a title "The Prince's Purse" finishes up as a filenem "Princes Purse, The" . BobC |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,308
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You can do pretty much anything you like in templates, since in calibre templates are basically an entire programming language. See http://manual.calibre-ebook.com/template_lang.html
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 691
Karma: 3026110
Join Date: Dec 2008
Location: Lancashire, U.K.
Device: BeBook 1, BeBook Pure, Kobo Glo, (and HD),Energy Sistem EReader Pro +
|
@Kovid,
I thought that would be the mechanism but have not had any experience of building them. I was hoping this was a problem that someone had solved already and that I wouldn't have to start learning a whole programming language to re-invent an already perfected wheel. BobC |
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,410
Karma: 8012664
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Use
Code:
{title_sort:re(',)} |
![]() |
![]() |
![]() |
#5 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
The template language is pretty simple, it contains a bunch of builtin functions() that you can apply directly to a {template}
Now, as Kovid implied, you can trivially create your own arbitrary functions in python as well. The builtin regular expressions function is pretty simple to use. Code:
{title_sort:re(',)} EDIT: ninjaed again... We have great timing and synchronicity, I see. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 691
Karma: 3026110
Join Date: Dec 2008
Location: Lancashire, U.K.
Device: BeBook 1, BeBook Pure, Kobo Glo, (and HD),Energy Sistem EReader Pro +
|
Thanks to you both. It was simpler than I though and I had just worked it out and tested it when I got both your answers.
I'd fiddled with the expression before but was trying to use a metadata plugboard and was tying myself in a knot. BobC |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Apostrophe in book title | scheife | Kindle Formats | 8 | 10-24-2017 04:55 AM |
Title page showing filename and not true book title... | hikerguy | Editor | 3 | 03-30-2015 05:37 PM |
Book Title from filename | EricBr | Kindle Formats | 3 | 06-17-2012 10:43 PM |
Error parsing templates when {authors} has an '&' or if {title} has a an apostrophe | sr2012 | Library Management | 1 | 04-30-2012 02:37 AM |
using filename for title | pj123 | Calibre | 1 | 05-22-2011 06:18 PM |