View Single Post
Old 09-10-2012, 06:06 PM   #9
unboggling
Wizard
unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.
 
Posts: 1,065
Karma: 858115
Join Date: Jan 2011
Device: Kobo Clara, Kindle Paperwhite 10
Quote:
Originally Posted by Man Eating Duck View Post
This one should do it:
Code:
program:format_number(add(add(strlen(field('title')),strlen(field('author_sort'))),0), '{0:d}')
You can replace the 0 with some integer because the path includes id and some padding. ...
Thank you, Man Eating Duck! That helped me considerably with the syntax. I learn something new every day around here.

I use this template for Saving Books to Disk:
Code:
{author_sort}/{title} - ({id})/{authors} - {series}{series_index:0>2s| | - }{title}
So to total characters of just the filename component of that path (not the folders), I would use this adaptation of the template provided by Man Eating Duck:

Code:
program:format_number(add(add(add(strlen(field('title')),strlen(field('authors'))),add(strlen(field('series')),strlen(field('series_index')))), 7), '{0:d}')
The integer 7 represents the space between series and series_index, plus space_dash_space times two (preceding and following series). I always have a series; even individual books have a placeholder series name and series_index "(1) 1". But, if I did have some empty series, real totals for empty series filenames would be 7 less 4 less. And the series_index formatting pads single digit index with leading zero, so in those cases the real total would be one higher. Edit: and add 4 or 5 to the total to accommodate the file extension I forgot to mention earlier.

That's just an example for filename alone in my Save to Disk template, not the actual calibre library path structure.

AFAIK, the calibre library path structure includes volume designation, folders down to and including LibraryName followed by
Code:
/{author1}/{title} ({id})/{title} - {author1}.ext
If there is more than one author in Author(s), calibre seems to use only the first author in the author folder and filename.

Last edited by unboggling; 09-11-2012 at 06:35 AM. Reason: clarification, 7 less --> 4 less
unboggling is offline   Reply With Quote