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 11-03-2019, 05:17 PM   #1
lduchastel
Junior Member
lduchastel began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Jan 2017
Device: Kindle Paperwhite
Help for complex Save to disk template

Hello,

I am not a programmer and I does not understand much regex but can manage some basic template functions.

I read dozens of posts about Save to disk issues and needs, and grabbed pieces of code here and there, but I am limited by my own incomprehension of programming language and complexity of my needs to make sense of all of them:

This what I would like to perform:

Code:
If custom field {#propername} exists, use that field only

   otherwise output filename as follow:

Authors (assuming all records are already Ln, Fn)
- Have last names in capitals
  {authors:'list_re_group($, ' & ', '.', '(.*?)(,|$)(.*)', '[[$:uppercase()]]')'}
- Use not more than two authors if more:
  {author:sublist(0,2,&)}
- Max length being 20 left characters
  {author:.20}

Year in parenthesis (assuming %Y in Format date as:)
  {pubdate:| (|) }

Series name
- Display if exists
- Max length being 20 left characters
  {series:.20| |}

Series index
- Display if exists
- with leading 0 and brackets
  {series_index:0>2s| [|] }

Title
- Colon character : in tile being replaced by --
  {title:re(:,--)}
- Max length being 70 left characters
- {title:.70}

Tweaks applied:
author_sort_copy_method = u'copy'
gui_pubdate_display_format = u'yyyy'
save_template_title_series_sorting = u'strictly_alphabetic'
For instance,

GALLO, Max & HART, John (2004) MBA Essentials [01] Accounting

I can make only some of the functions to work at the same time, but cannot make them to work all at the same time.

Is a single template disk line can do that ?
Otherwise, what I should do ?

Thanks for any advice.

Thank you
lduchastel is offline   Reply With Quote
Old 11-03-2019, 05:25 PM   #2
lduchastel
Junior Member
lduchastel began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Jan 2017
Device: Kindle Paperwhite
In addition to my question, is it possible to populate a custom field with result of template ?

My {#properfilename} can be used to have a nicely custom-formatted filename that would be permanent, but it would save me a lot by first populating it with above specifications before hand-editing it.

I worked in an higher education environment where I try to have filename of books exported from Calibre to follow bibliographical norms whenever possible.
lduchastel is offline   Reply With Quote
Advert
Old 11-04-2019, 08:27 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: 140
Karma: 76596
Join Date: Feb 2015
Location: Portugal
Device: Kobo Aura HD
Can you post your entire template line here?

I'm not a coder too and after reading many posts I ended up with this template that I can live with:
Code:
{author_sort:.20s:sublist(0,1,&)}/{author_sort:.28s:sublist(0,1,&)}{title:re(\,,_)|--|}/{author_sort:.28s:sublist(0,1,&)}{pubdate:| (|)}{series:.20s| [|}{series_index:0>2s|-|]}{title:.50:re(\,,_)|--|}
Outputs:
Author Sort/Author Sort--Title/Author Sort [Series-03]--Title
Real file name :
Livingstone,_John_Doe_(2019)_[My_series_title_with-01]--The_Working_Title__in_Progress.epub

You can see that I use an output with folders and a variation on the series punctuation.
Also test output into a short path folder (A folder directly at the root drive) to avoid issues caused by long file names being too shortened (maybe avoid the second author's name can be useful to keep the title name!.

Related post:
https://www.mobileread.com/forums/sh...d.php?t=323263


Note: Maybe you should create a different topic on the "populate a custom field from a name template"

Last edited by Horus68; 11-04-2019 at 11:37 AM.
Horus68 is offline   Reply With Quote
Old 11-04-2019, 09:14 AM   #4
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: 140
Karma: 76596
Join Date: Feb 2015
Location: Portugal
Device: Kobo Aura HD
*UPDATED
The tweek gui_pubdate_display_format only applies to GUI not to Save to disk template.
To have {pubdate:| (|) } display the date as (2019) you need to change the option "Format date as" in Saving to disc screen (see image)
Attached Thumbnails
Click image for larger version

Name:	calibre - Preferences - Saving books to disc.png
Views:	98
Size:	14.6 KB
ID:	174717  

Last edited by Horus68; 11-04-2019 at 11:38 AM. Reason: Wrong info
Horus68 is offline   Reply With Quote
Old 11-04-2019, 10:21 AM   #5
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: 140
Karma: 76596
Join Date: Feb 2015
Location: Portugal
Device: Kobo Aura HD
Using an working example, not able to get all that you want but this the best I can do:

Title: The Working Title: in Progress
Authors: John Doe Livingstone & Jane Doe Bernadette
Series: My series title with several words
Series Number: 1.00
Date: 2019


Using the tweek:
Code:
author_sort_copy_method = u'invert'
save_template_title_series_sorting = u'strictly_alphabetic'
Save to disk template
Code:
{author_sort:'list_re_group($, ' & ', '.', '(.*?)(,|$)(.*)', '[[$:uppercase()]]')'}{pubdate:| (|)} {series:.20s| |}{series_index:0>2s| [|]} {title:.70:re(:,--)||}
Outputs:
LIVINGSTONE, John Doe & BERNADETTE, Jane Doe (2019) My series title with [01] The Working Title-- in Progress.epub

Notes:
using: author_sort:.20 in the file name as in
Code:
{author_sort:.20:'list_re_group($, ' & ', '.', '(.*?)(,|$)(.*)', '[[$:uppercase()]]')'}{pubdate:| (|)} {series:.20s| |}{series_index:0>2s| [|]} {title:.70:re(:,--)||}
to limit max length being 20 left characters applies to the complete output value (all authors listed) so the second author will be cut off most of the times. Maybe you should left .20 out

Last edited by Horus68; 11-04-2019 at 11:45 AM.
Horus68 is offline   Reply With Quote
Advert
Old 11-04-2019, 04:20 PM   #6
lduchastel
Junior Member
lduchastel began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Jan 2017
Device: Kindle Paperwhite
Thumbs up Thank you !

Thank you a lot Horus68 !
This is exactly what I needed!

I just changed your code with author_sort:.28s.

Code:
{author_sort:.28s:'list_re_group($, ' & ', '.', '(.*?)(,|$)(.*)', '[[$:uppercase()]]')'}{pubdate:| (|)} {series:.20s| |}{series_index:0>2s| [|]} {title:.70:re(:,--)||}


Do you know, by any chance, if it is possible to have ALSO the template to include a choice between two options: 1) if {#properfilename} exists, use it as filename, 2) if not use code above ?

And is it possible to have the above code to pre-populate an empty {#properfilename] field ?

My view is no matter what, a template would never beat human intelligence for giving the perfect filename considering the length barrier, and a hand-edited fixed filename in {#properfilename} could be used whenever possible. I would like to pre-populate such custom field with template to keep hand-editing minimal.
lduchastel is offline   Reply With Quote
Reply

Tags
save to disk, template


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Save to Disk Template Help Tanjamuse Library Management 2 08-09-2019 09:35 AM
Save to Disk Template Amanda5177 Library Management 8 01-09-2019 01:09 PM
save to disk template help bilaly Library Management 2 10-19-2018 07:19 PM
Please help on a Save to Disk template Dammie Library Management 15 12-16-2013 09:51 AM
save to disk template speakingtohe Calibre 9 05-29-2010 06:02 AM


All times are GMT -4. The time now is 09:19 PM.


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