Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 09-08-2012, 06:02 PM   #1
miquele
Connoisseur
miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.
 
miquele's Avatar
 
Posts: 75
Karma: 498122
Join Date: May 2010
Location: Europe
Device: Bookeen Cybook Gen3, Kindle 3, Kindle PW, Kindle Voyage
custom column: count number of characters (in book path)

hello,
due to limitations in my Windows XP filesystem, I'd like to have a custom column showing the number of characters of title + author.

the best I managed was a build from other columns, the template is:
{author:strlen()}+{title:strlen()}
.
Thing is the custom column now shows s.th. like '12+15'. It's not bad for starters, but no good either - you can't sort that.

I also tried to work with add({author:strlen()}, {title:strlen()}), also to no avail [it shows 'add(12,15)'].
Any ideas how I can get a real number out of that, to make that sortable?

That would be great.
Cheers, miquele

Last edited by miquele; 09-08-2012 at 06:08 PM.
miquele is offline   Reply With Quote
Old 09-08-2012, 06:08 PM   #2
miquele
Connoisseur
miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.
 
miquele's Avatar
 
Posts: 75
Karma: 498122
Join Date: May 2010
Location: Europe
Device: Bookeen Cybook Gen3, Kindle 3, Kindle PW, Kindle Voyage
Should have posted to library management, sorry. Can't delete or move it ...
miquele is offline   Reply With Quote
Old 09-08-2012, 08:22 PM   #3
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
See an older thread:

Sort library by length of title (or author, etc) ?

The one there is for Title length alone though. I'm ignorant about template functions - maybe someone else can help you total similar template for author with the one for title all in one template.

Last edited by unboggling; 09-08-2012 at 08:48 PM.
unboggling is offline   Reply With Quote
Old 09-10-2012, 11:54 AM   #4
Man Eating Duck
Addict
Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.
 
Posts: 254
Karma: 69786
Join Date: May 2006
Location: Oslo, Norway
Device: Kobo Aura, Sony PRS-650
Quote:
Originally Posted by unboggling View Post
The one there is for Title length alone though. I'm ignorant about template functions - maybe someone else can help you total similar template for author with the one for title all in one template.
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.

I thought that Calibre automatically restricted total path length on windows, cropping as necessary? If this is a problem for you, you could also use something like vSubst (untested by me) from this page to make a "shortcut" to a folder disguised as a drive letter, and point Calibre to that instead.
Man Eating Duck is offline   Reply With Quote
Old 09-10-2012, 11:56 AM   #5
miquele
Connoisseur
miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.
 
miquele's Avatar
 
Posts: 75
Karma: 498122
Join Date: May 2010
Location: Europe
Device: Bookeen Cybook Gen3, Kindle 3, Kindle PW, Kindle Voyage
thanks for the hint, still cannot work it out. E.g. add(format_number({author:strlen()}),format_number ({title:strlen()}))
would result in
add(format_number(13),format_number(10))
. Just wouldn't add those two freaking numbers
miquele is offline   Reply With Quote
Old 09-10-2012, 12:58 PM   #6
miquele
Connoisseur
miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.
 
miquele's Avatar
 
Posts: 75
Karma: 498122
Join Date: May 2010
Location: Europe
Device: Bookeen Cybook Gen3, Kindle 3, Kindle PW, Kindle Voyage
Yay - thanks Man Eating Duck!!

The reason is indirectly within Calibre. Calibre2opds seems to have a certain limit, and my path is kinda deep - so I have only a limited number of chars for that in Calibre to work.

Your formula is perfect, what's the 'program' for?
miquele is offline   Reply With Quote
Old 09-10-2012, 01:42 PM   #7
Man Eating Duck
Addict
Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.
 
Posts: 254
Karma: 69786
Join Date: May 2006
Location: Oslo, Norway
Device: Kobo Aura, Sony PRS-650
Quote:
Originally Posted by miquele View Post
Your formula is perfect, what's the 'program' for?
Glad it works for you

The 'program' is there so that it's treated as an algorithm, this allows nested functions and control structures, not just fields.

I would still have a look at vsubst if I were you, that should mitigate the problem.

The link is http://home.datacomm.ch/t.bigler/s04.html

Last edited by Man Eating Duck; 09-10-2012 at 01:43 PM. Reason: typo
Man Eating Duck is offline   Reply With Quote
Old 09-10-2012, 02:43 PM   #8
miquele
Connoisseur
miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.
 
miquele's Avatar
 
Posts: 75
Karma: 498122
Join Date: May 2010
Location: Europe
Device: Bookeen Cybook Gen3, Kindle 3, Kindle PW, Kindle Voyage
I'll take a look to circumvent that for the future :-)
miquele is offline   Reply With Quote
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
Old 09-11-2012, 03:04 AM   #10
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,731
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by unboggling View Post
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}')
Excellent! I put a lot of work into template general program mode and it is nice to see people using it.

The following template will have significantly better performance and is (for me) easier to read. Like unboggling's template, it computes the length of the filename (the last component).
Code:
program: strlen(template('{authors} - {series}{series_index:0>2s| | - }{title}'))
This one computes the length of the entire path including the folders.
Code:
program: strlen(template('{author_sort}/{title} - ({id})/{authors} - {series}{series_index:0>2s| | - }{title}'))
And as long as I am in demonstration mode, the following will produce the same answer as the one provided by Man Eating Duck, but with better performance.
Code:
program: strlen(strcat(field('title'), field('author_sort')))
This works because "length(title) + length(author_sort)" equals "length(title concatenated with author_sort)". There is no need to use the format_number function in this case because what is desired is just the number. You would use format_number if you want embedded commas or the like.

Note that the strcat function can accept more than two arguments, so you can say something like
Code:
program: strlen(strcat(field('title'), field('author_sort'), field('series')))
chaley is offline   Reply With Quote
Old 09-11-2012, 05:24 AM   #11
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
@chaley, thank you for the examples/demos.

My eyes got wide and my jaw dropped open. The template language is so cool !!!

I'll play with your examples tomorrow when I'm fresher. And then adapt if necessary and incorporate them into "How I Manage", in Configurations - Templates - Examples. And point to that subsection from workflow where I mention in passing that some users want shorter filenames.

unboggling is offline   Reply With Quote
Old 09-11-2012, 09:11 AM   #12
mdb5972
Member
mdb5972 began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Jan 2011
Device: Sony PRS350
Thank you
mdb5972 is offline   Reply With Quote
Old 09-11-2012, 12:09 PM   #13
Man Eating Duck
Addict
Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.Man Eating Duck juggles neatly with hedgehogs.
 
Posts: 254
Karma: 69786
Join Date: May 2006
Location: Oslo, Norway
Device: Kobo Aura, Sony PRS-650
Quote:
Originally Posted by chaley View Post
Excellent! I put a lot of work into template general program mode and it is nice to see people using it.
Absolutely, it's amazingly versatile, thanks a lot for creating it! There are limits to how much trickery I actually *need* in a custom column, but it's very nice to have the possibility to include quite a lot of it
Man Eating Duck is offline   Reply With Quote
Old 09-11-2012, 08:30 PM   #14
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 chaley View Post
Excellent! I put a lot of work into template general program mode and it is nice to see people using it.
@chaley, thank you again for those examples! And thank you for the template language in general. I incorporated those examples in "How I" - Configurations - Templates. I'll gradually add other examples, and gradually add verbal pointers to them from within relevant workflow sections.

@anyone, do you happen to have, already constructed, a template for the entire path used by calibre for its library? Or a way to grab entire path from calibre internals and use that in a template? I can construct one for my specific path from root level all the way through to file extension, but that seems too specific for OS X and my library to include in "How I". An ideal character-counting template (for books in calibre library) would:
- include all path components
- be interoperable across various OSs and filesystems
- include a general designation meaning "drive letter and/or the volume name"
- include a general designation meaning "username"
- include a general designation meaning "library name"
- include just the first author (edit: extracted from {authors})
- include the file extension (edit: extracted from {formats})

Is there a shorthand interoperable among various file systems, such as ".." to mean "all path components from root to here", and another for "file extension"? Or an even more abbreviated shorthand to mean "the entire path from root of this file all the way through extension"?

Edit: And to complicate things further, is there a way to automatically capture the string length after calibre does whatever it does to truncate per filesystem?

Last edited by unboggling; 09-11-2012 at 09:17 PM. Reason: clarify
unboggling is offline   Reply With Quote
Old 09-12-2012, 06:57 PM   #15
miquele
Connoisseur
miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.miquele ought to be getting tired of karma fortunes by now.
 
miquele's Avatar
 
Posts: 75
Karma: 498122
Join Date: May 2010
Location: Europe
Device: Bookeen Cybook Gen3, Kindle 3, Kindle PW, Kindle Voyage
you're awesome, thanks a million, guys
miquele is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom column showing path length? xterminal Library Management 1 09-11-2012 09:12 AM
Custom column to display number of chapters? crackshot91 Library Management 10 09-08-2012 04:56 PM
Can custom book data be displayed in a custom column? kiwidude Development 9 03-02-2011 05:35 AM
Custom column for book added gandor62 Library Management 1 03-01-2011 06:58 AM
Custom Column - Book Format (ie mobi, epub etc) jphphotography Calibre 3 01-17-2011 12:34 AM


All times are GMT -4. The time now is 01:02 AM.


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