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 06-13-2019, 04:10 PM   #1
cbook7
Junior Member
cbook7 began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jun 2019
Device: Various
Question Request: Match Calibre Filename template recipe

Hi,

I need to ensure that 'Save to disk' and 'Send To Device' use the same filename that Calibre assigns to books in the library.

The format seems to be:

book_title (up to X chars max) - 1st_author (up to Y chars max)

and characters '?' and ':' (possibly others?) are replaced by an underscore


From what I can tell this could be via a Template, but is sadly way over my head. I'd be very grateful if anyone could provide a recipe for this. If X and Y are not known leave them as x an y. I'll have a play around to figure them out.

Many thanks,

Cal
cbook7 is offline   Reply With Quote
Old 06-13-2019, 07:56 PM   #2
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,572
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by cbook7 View Post
Hi,

I need to ensure that 'Save to disk' and 'Send To Device' use the same filename that Calibre assigns to books in the library.

The format seems to be:

book_title (up to X chars max) - 1st_author (up to Y chars max)

and characters '?' and ':' (possibly others?) are replaced by an underscore


From what I can tell this could be via a Template, but is sadly way over my head. I'd be very grateful if anyone could provide a recipe for this. If X and Y are not known leave them as x an y. I'll have a play around to figure them out.
As far as I know the rules for formulating folder and file names within calibre libraries are embedded in the code, they're also platform, file system, and language dependent. And those rules are subject to change, as they have done in the past.

An example of when they might change is when 32Kb file and folder names become commonplace in Windows.

BR
BetterRed is offline   Reply With Quote
Advert
Old 06-13-2019, 08:33 PM   #3
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
I'm pretty sure @chaley gave me a template for extracting Calibre filenames. I think it uses {formats}? Let me try searching for that post.
ilovejedd is offline   Reply With Quote
Old 06-13-2019, 08:39 PM   #4
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
Found it. It relies on a file with the selected format existing, though (e.g. MOBI in the example below).

Quote:
Originally Posted by chaley View Post
Clearly the lexical analyser is broken. That doesn't really surprise me, given I used regexps to parse strings.

The problem is that the \" is recognized before the \\. This formulation gets rid of the \" by using a character class to change the backslashes into colons, so the problem goes away.
Code:
{:'sublist(re(select(formats_paths(),"MOBI"), '[\\]', ':'), -1,0,":")'}
This formulation gets rid of the sublist, depending on greedy regular expressions
Code:
{:'re(select(formats_paths(),"MOBI"), '.*[\\]', '')'}
ilovejedd is offline   Reply With Quote
Old 06-14-2019, 04:43 AM   #5
cbook7
Junior Member
cbook7 began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jun 2019
Device: Various
Thanks @ilovejedd!

Hmmm, though if it's the case that "they're also platform, file system, and language dependent. And those rules are subject to change, as they have done in the past" as @BetterRed says, I may need to rethink this.
cbook7 is offline   Reply With Quote
Advert
Old 06-14-2019, 07:24 AM   #6
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,572
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@cbook7 - why don't you tell us what you're trying to achieve.

BR
BetterRed is offline   Reply With Quote
Old 06-16-2019, 06:53 AM   #7
cbook7
Junior Member
cbook7 began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jun 2019
Device: Various
Quote:
Originally Posted by BetterRed View Post
@cbook7 - why don't you tell us what you're trying to achieve.

BR
I want to sync bookmarks (and page position) across devices using Moon+ consistently, regardless of import method in a futureproof way.

I use CC to add books to the device using either 'Wireless Device' or 'Content Server' methods. I use CC's option to always override filenames, so the books have the same name regardless of which import method used.

This is fine when I know I want a book ahead of time. However, I use pCloud for cloud storage which is not supported by CC. CC doesn't support the Webdav protocol either.

I can still remotely (when away from home/my laptop) download a book from Calibre to my android device, by finding the file in my cloud based Calibre library using my pCloud app to export it to the device storage. However, this bypases CC so it no longer gets renamed. Instead it retains its Calibre library filename.

My idea was to make Calibre use it's own filename for the book when sending to a device (hence my original question). Then in CC using the setting that requests Calibre also use the 'Wireless Device' import filename for 'Content Server' imports. Thus all 3 methods of import have a consistent filename - that assigned by Calibre in it's library structure.

However, if in the future (or on a different OS) Calibre changes its internal file-naming of books it would break.

Options (As I see them)
================
  • Hope CC implements Webdav support
    Doesn't see likely from previous comments made by the CC dev
  • Manually rename files import through my pCloud app to match the CC name convention
    (my current plan) Obviously not ideal but maybe manageable given I don't anticipate requiring that many books (that I expect to bookmark) via the cloud route (i.e. unexpectedly). Also helped by the fact that CC allows a {title} - {first_author} naming convention, matching what my Calibre (Linux) currently uses. So some files wouldn't need renaming (a number would however, due to Calibre truncating long titles names which CC doesn't.)
  • Find some Android app which books can be sent/shared to (from cloud app) which then automatically renames them from metadata (using a customized format to match CC), and saves them to the desired location automatically.
    This would work fine, I'm just don't think such an app exists. I've not been able to find one at least.

If you've any comments or suggestions I'd gladly hear them
cbook7 is offline   Reply With Quote
Old 06-16-2019, 08:47 PM   #8
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,572
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
The only tentative suggestion I can make would be to use a cloud storage service that CC does support rather than pcloud. Tentative a) because you maybe locked in to pcloud, b) I don't use CC nor anything similar so I'm not entirely sure that would solve your problem anyway.

Maybe ilovejedd will have some ideas

BR
BetterRed is offline   Reply With Quote
Old 06-16-2019, 09:17 PM   #9
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
I think easiest way (apart from using CC supported cloud service) is to use the same filename template for CC and pCloud copies.

Personally, I actually have 2 sets of my books on Dropbox:
One is a complete/direct mirror of my Calibre library (my offsite backup)
The other uses {genre}/{author}/{author} - {series} {series_index} - {title} (for easy browsing on Marvin for iOS).
ilovejedd is offline   Reply With Quote
Old 06-17-2019, 08:30 AM   #10
cbook7
Junior Member
cbook7 began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jun 2019
Device: Various
Quote:
Originally Posted by ilovejedd View Post
I think easiest way (apart from using CC supported cloud service) is to use the same filename template for CC and pCloud copies.
Yes, I'll see how I get on doing this (manually) when required.

While I'm not locked into pCloud I'm not looking to change because it fits very with my wider data/cloud needs and my wallet ;-). I actually switched to pCloud after 5 years with a paid Dropbox account and am quite satisfied with it so far (inconveniences like this aside!).

Thanks for the feedback

Last edited by cbook7; 06-17-2019 at 08:32 AM.
cbook7 is offline   Reply With Quote
Old 06-05-2020, 05:11 AM   #11
mathissimo
Junior Member
mathissimo began at the beginning.
 
Posts: 3
Karma: 12
Join Date: Feb 2017
Device: Pocketbook Touch Lux 3
Quote:
Originally Posted by cbook7 View Post
I want to sync bookmarks (and page position) across devices using Moon+ consistently, regardless of import method in a futureproof way.
I have almost the same use-case, as I am not using CC for syncing, but a folder device and a sync-service (eg Dropbox). My approach was simply to change the filename-format of the folder device according to the (hard-coded) Calibre Server format.

For those, who like to go down this road. The appropriate format was:
Code:
{author_sort:sublist(0,1,&)}_{title}
You also need to change the {title} behaviour in Prefrences/Tweaks/Control formatting of title and series when used in templates to
Code:
save_template_title_series_sorting = u'strictly_alphabetic'
as described here.
mathissimo is offline   Reply With Quote
Reply

Tags
recipe, template


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
WSJ (paid) recipe - request for filename/title change stualden Recipes 4 09-13-2019 09:53 AM
Change filename template in Calibre's library 8140david Library Management 3 09-25-2016 11:39 AM
Feature Request: preserving original filename Giuseppe Chillem Calibre 23 01-16-2013 02:45 AM
Feature request: change filename Fitz Library Management 11 07-19-2011 04:21 PM
filename template feature artbatista Calibre 0 08-23-2009 01:05 PM


All times are GMT -4. The time now is 09:55 AM.


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