09-08-2012, 06:02 PM | #1 |
Connoisseur
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. |
09-08-2012, 06:08 PM | #2 |
Connoisseur
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 ...
|
09-08-2012, 08:22 PM | #3 |
Wizard
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. |
09-10-2012, 11:54 AM | #4 | |
Addict
Posts: 254
Karma: 69786
Join Date: May 2006
Location: Oslo, Norway
Device: Kobo Aura, Sony PRS-650
|
Quote:
Code:
program:format_number(add(add(strlen(field('title')),strlen(field('author_sort'))),0), '{0:d}') 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. |
|
09-10-2012, 11:56 AM | #5 |
Connoisseur
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 |
09-10-2012, 12:58 PM | #6 |
Connoisseur
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? |
09-10-2012, 01:42 PM | #7 |
Addict
Posts: 254
Karma: 69786
Join Date: May 2006
Location: Oslo, Norway
Device: Kobo Aura, Sony PRS-650
|
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 |
09-10-2012, 02:43 PM | #8 |
Connoisseur
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 :-)
|
09-10-2012, 06:06 PM | #9 | |
Wizard
Posts: 1,065
Karma: 858115
Join Date: Jan 2011
Device: Kobo Clara, Kindle Paperwhite 10
|
Quote:
I use this template for Saving Books to Disk: Code:
{author_sort}/{title} - ({id})/{authors} - {series}{series_index:0>2s| | - }{title} Code:
program:format_number(add(add(add(strlen(field('title')),strlen(field('authors'))),add(strlen(field('series')),strlen(field('series_index')))), 7), '{0:d}') 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 Last edited by unboggling; 09-11-2012 at 06:35 AM. Reason: clarification, 7 less --> 4 less |
|
09-11-2012, 03:04 AM | #10 | |
Grand Sorcerer
Posts: 11,731
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
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}')) Code:
program: strlen(template('{author_sort}/{title} - ({id})/{authors} - {series}{series_index:0>2s| | - }{title}')) Code:
program: strlen(strcat(field('title'), field('author_sort'))) 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'))) |
|
09-11-2012, 05:24 AM | #11 |
Wizard
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. |
09-11-2012, 09:11 AM | #12 |
Member
Posts: 18
Karma: 10
Join Date: Jan 2011
Device: Sony PRS350
|
Thank you
|
09-11-2012, 12:09 PM | #13 | |
Addict
Posts: 254
Karma: 69786
Join Date: May 2006
Location: Oslo, Norway
Device: Kobo Aura, Sony PRS-650
|
Quote:
|
|
09-11-2012, 08:30 PM | #14 | |
Wizard
Posts: 1,065
Karma: 858115
Join Date: Jan 2011
Device: Kobo Clara, Kindle Paperwhite 10
|
Quote:
@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 |
|
09-12-2012, 06:57 PM | #15 |
Connoisseur
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
|
Thread Tools | Search this Thread |
|
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 |