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 01-05-2022, 04:34 PM   #1
Rand Brittain
Bookmaker
Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.
 
Posts: 416
Karma: 2143650
Join Date: Sep 2010
Device: Cybook Opus
Transforming Filenames With Special Characters

Is there a way to use templates or plugboards to set Calibre up so that when I send a file to a device that has an illegal character in the metadata (specifically, a colon), it transforms that character into something other than _?

I'm trying to use Calibre to manage my collection of RPG PDFs, and RPGs love having titles with colons in them, like Vampire: the Masquerade and its ilk. I'd like to be able to set things up so that the transfer sends these files to device with the filename of, more or less "Vampire — the Masquerade" instead of "Vampire_ the Masquerade". That is, it turns a colon into space-emdash-space.

Can Calibre do this automatically? I've looked at the documents but I'm not too great at regular expressions.
Rand Brittain is offline   Reply With Quote
Old 01-05-2022, 05:25 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,801
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Colon is illegal in windows, there is a FAQ on WHY Calibre prefers simple ASCII names (it is only allowd as part of a device (A:, Com1:, Aux: LPT1: )
Other symbols have meaning to various OS. Calibre works across many OS, so K.I.S.S. is the rule.
theducks is offline   Reply With Quote
Advert
Old 01-05-2022, 09:04 PM   #3
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,568
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
I think the OP knows why the '_' (underscore) character is substituted for disallowed characters (e.g. <>:"/\|?*) in file names.

What they want to do is to use another substitute character in Save to Disk, Send to Device templates and plugboards etc. Or even better a substitute string e.g. ' — '.

Personally, I would get rid of the ':' in the Title when I added the book, either via use of a subtitle column or by changing the ':' to ' — '. But that wouldn't suit everyone.

BR

Last edited by BetterRed; 01-05-2022 at 09:29 PM.
BetterRed is offline   Reply With Quote
Old 01-05-2022, 09:29 PM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
If you are fiddling with the metadata that will be inside the book, you can use the metadata plugboard to make the changes you want. But, these won't affect the file names.

For the file names, the save template is used. There is a default save template on the "Sending books to devices" page of the preferences. That will be used for any device you have not done any configuration to. As this is probably a devices specific thing, configure this in the driver used by your device. The simplest way to do that, is to connect the device, wait for the device jobs to run and then right-click the device button and select the option to configure the device. That will make sure you get the right driver.

The default save template is:

Code:
{author_sort}/{title} - {authors}
For what you want, you could do is:
Code:
{author_sort}/{title: re(: , - )} - {authors}
Though I would do it in general program mode as:

Code:
program:
strcat($author_sort, "/", re($title, ":" , " -"), " - ", $authors)
Which I find that version a lot easier to read.

In both cases, the "re" is a regex replacement, so the parameters are regex to match and the string to replace all the matches with.

After this has been executed, calibre will still sanitise result. Which will make sure whatever is produced is valid on the filesystem and the device in question.
davidfor is offline   Reply With Quote
Old 01-05-2022, 09:42 PM   #5
Rand Brittain
Bookmaker
Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.
 
Posts: 416
Karma: 2143650
Join Date: Sep 2010
Device: Cybook Opus
Quote:
Originally Posted by davidfor View Post
If you are fiddling with the metadata that will be inside the book, you can use the metadata plugboard to make the changes you want. But, these won't affect the file names.

For the file names, the save template is used. There is a default save template on the "Sending books to devices" page of the preferences. That will be used for any device you have not done any configuration to. As this is probably a devices specific thing, configure this in the driver used by your device. The simplest way to do that, is to connect the device, wait for the device jobs to run and then right-click the device button and select the option to configure the device. That will make sure you get the right driver.

The default save template is:

Code:
{author_sort}/{title} - {authors}
For what you want, you could do is:
Code:
{author_sort}/{title: re(: , - )} - {authors}
Though I would do it in general program mode as:

Code:
program:
strcat($author_sort, "/", re($title, ":" , " -"), " - ", $authors)
Which I find that version a lot easier to read.

In both cases, the "re" is a regex replacement, so the parameters are regex to match and the string to replace all the matches with.

After this has been executed, calibre will still sanitise result. Which will make sure whatever is produced is valid on the filesystem and the device in question.
Yes, thank you; this is just what I needed!

What's the correct way to do the second format if what I was currently using was:

Code:
{author_sort}/{#line}/{#subline}/{#edition}
Would it be:

Code:
program:
strcat($author_sort, "/", $#line, "/" $#subline, "/", $#edition, "/", re($title, ":" , " -"), " - ", $authors)
Rand Brittain is offline   Reply With Quote
Advert
Old 01-05-2022, 10:13 PM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by Rand Brittain View Post
Yes, thank you; this is just what I needed!

What's the correct way to do the second format if what I was currently using was:

Code:
{author_sort}/{#line}/{#subline}/{#edition}
Would it be:

Code:
program:
strcat($author_sort, "/", $#line, "/" $#subline, "/", $#edition, "/", re($title, ":" , " -"), " - ", $authors)
Other than the missing comma before $#subline, that should be correct.

But, I feel like there should be a better way to do that, but, I can't see a "format_as_path" or the equivalent of "os.join()".
davidfor is offline   Reply With Quote
Old 01-05-2022, 11:09 PM   #7
Rand Brittain
Bookmaker
Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.
 
Posts: 416
Karma: 2143650
Join Date: Sep 2010
Device: Cybook Opus
Thanks a bunch!
Rand Brittain is offline   Reply With Quote
Old 01-21-2022, 12:43 PM   #8
Rand Brittain
Bookmaker
Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.Rand Brittain ought to be getting tired of karma fortunes by now.
 
Posts: 416
Karma: 2143650
Join Date: Sep 2010
Device: Cybook Opus
Hm, after testing this, it looks like doing this with an endash actually results in the filename being transformed as requested, but it outputs a hyphen instead. If I use an emdash, it outputs two hyphens.

Odd! I know the filesystems I use are okay with endash and emdash, but maybe some of them aren't and so Calibre won't use them? Or could it be a bug?
Rand Brittain is offline   Reply With Quote
Old 01-21-2022, 12:55 PM   #9
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,401
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by Rand Brittain View Post
Hm, after testing this, it looks like doing this with an endash actually results in the filename being transformed as requested, but it outputs a hyphen instead. If I use an emdash, it outputs two hyphens.

Odd! I know the filesystems I use are okay with endash and emdash, but maybe some of them aren't and so Calibre won't use them? Or could it be a bug?
Very likely that calibre is using the ASCII character set which does not include an en or em dash. As mentioned above, this helps to avoid issues with OS where one of those characters might be invalid in a file name.
DNSB is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forma Can't read .cbz files with special characters in the .jpg filenames JawadLeLogeur Kobo Reader 3 06-24-2021 09:53 AM
Enhancement request: special characters, invisible characters and html entities. PenguinCEO Editor 15 04-08-2020 05:26 PM
Change characters in metadata title and filenames on disk NickKnaque Calibre 16 10-24-2019 10:07 AM
Special CHaracters Rellwood Calibre 10 05-01-2019 10:43 PM
Special Characters abbotrichard ePub 4 07-01-2011 06:03 PM


All times are GMT -4. The time now is 01:59 PM.


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