Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 08-23-2018, 05:07 PM   #1
manawydan
Connoisseur
manawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toysmanawydan shares his or her toys
 
Posts: 95
Karma: 5854
Join Date: Aug 2011
Device: none
Question Save to disk - how to avoid underscore _?

Whenever Calibre saves ebooks to disk which contain : or , or ? in the title, these (and other) characters will be replaced by an underscore _.

There must be an option to set a substitute but where?

I'd like to replace : with -
e.g. "you and me: a memoir" = "you and me - a memoir"
and , or ; with _
e.g. "you, he, me" = "you he me"

At the moment I can only do it with search/replace in edit metadata or outside Calibre with an additional software.

I can't find anything in tweaks and am not experienced enough to do it with plugboards or a regular expression in preferences-save to disk.

I have to use 1.47 and no, I can not upgrade.
However the principle of how to do it will most likely be the same regardless which version you use.
manawydan is offline   Reply With Quote
Old 08-23-2018, 11:04 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The way to do it is to use a template. https://manual.calibre-ebook.com/template_lang.html
kovidgoyal is offline   Reply With Quote
Advert
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
Old 01-03-2021, 04:29 PM   #4
mfaine1
Member
mfaine1 began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Oct 2020
Device: Kindle
In case anyone else finds this while searching for a way to fix the underscore problem.
Here is my solution for now, though I wonder if a plugin that does something similar couldn't be developed. If I ever take the time to learn how to write plugins for Calibre this will be the first one I tackle. I think a template wouldn't work because the part of the code that replaces the special characters is applied after the template?? If I'm wrong about this that would be great.

Here is a script that you can run with the export directory path as an argument after exporting the files from Calibre and it will rename them based on the metadata in the opf file. If you want to improve on this and repost it that would be great. I'm sure there is a lot that could be improved.
mfaine1 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Save to disk arcegabriel Calibre 8 03-16-2018 08:47 PM
Save to Disk Dethmaul Library Management 2 09-03-2015 01:11 AM
Save to Disk help Dethmaul Library Management 1 05-01-2014 03:51 PM
Save to Disc - Folder name - Period changes to Underscore Gutenberg Library Management 4 09-17-2012 10:48 AM
Save on disk PhM Calibre 1 06-13-2011 12:43 PM


All times are GMT -4. The time now is 04:15 PM.


MobileRead.com is a privately owned, operated and funded community.