View Single Post
Old 09-26-2019, 10:24 AM   #3
Horus68
Zealot
Horus68 understands the mechanisms of the catecholamine pathways.Horus68 understands the mechanisms of the catecholamine pathways.Horus68 understands the mechanisms of the catecholamine pathways.Horus68 understands the mechanisms of the catecholamine pathways.Horus68 understands the mechanisms of the catecholamine pathways.Horus68 understands the mechanisms of the catecholamine pathways.Horus68 understands the mechanisms of the catecholamine pathways.Horus68 understands the mechanisms of the catecholamine pathways.Horus68 understands the mechanisms of the catecholamine pathways.Horus68 understands the mechanisms of the catecholamine pathways.Horus68 understands the mechanisms of the catecholamine pathways.
 
Horus68's Avatar
 
Posts: 143
Karma: 76596
Join Date: Feb 2015
Location: Portugal
Device: Kobo Aura HD
Done reading that tutorial but its hard for me to understand the code partes without a live example. My bad... so much to learn and I'm not a programmer!
Can someone paste me an example for replacing a : in title with - (for the save to disk template)
Then I can play with it and find some other uses (as in removing punctuation marks form file name)!

Update, giving a copy/paste ready example:
Using re(pattern, replacement)
(the details are in the quoted tutorial: https://manual.calibre-ebook.com/template_lang.html )

Actual behaviour:
When a title field has a value with ":" (as in "Title: subtitle") the ":" would cause a filename with "_space" instead of the ":" as in the file name
Code:
Title_ subtitle.pdf
Instead... you can have a filename with "space-" as in "Title - subtitle".
For that use this in "Save to disk" Template (for the title field part)
Code:
{title:re(:, -)}
I'm sure there could be better solutions as I'm a newbie and probably only useful for other newbies like me.

Related topics with same question
https://www.mobileread.com/forums/sh...d.php?t=263504
https://www.mobileread.com/forums/sh...d.php?t=169516

Last edited by Horus68; 09-28-2019 at 06:30 AM.
Horus68 is offline   Reply With Quote