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 03-07-2015, 09:55 PM   #1
Thomas_AR
Connoisseur
Thomas_AR began at the beginning.
 
Thomas_AR's Avatar
 
Posts: 76
Karma: 10
Join Date: Jan 2015
Location: Buenos Aires
Device: Android
Template for sending to device

Well i am loving more and more C-Companion as it is much easier to manage a huge ebook collection in conjunction with a tablet.

I like to get a folder structure when sending books from calibre to my tablet for better file browsing:

For now i have following template:
{series:'ifempty($, field('authors'))'}/{series_index:0>4s| | - }{title} - {authors}
This results in:
When book has a "series, series index, author and title:
"series/series index(for digits) - title - author
if no series simply
"author/title - author"

Now for easier browsing I would love to have, in case i have a series, for example the letteres "SR - "at the beginning of a Serie folder.
"SR - {series}/series index - etc

Any idea how to do that?

Last edited by Thomas_AR; 03-07-2015 at 10:48 PM.
Thomas_AR is offline   Reply With Quote
Old 03-08-2015, 01:11 AM   #2
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 12,663
Karma: 30811118
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Begin with the template fragment:
Code:
{series:'test($, strcat("SR - ", field("series")), field("authors")))'}
eschwartz is offline   Reply With Quote
 
Advertisement
Old 03-08-2015, 10:47 AM   #3
Thomas_AR
Connoisseur
Thomas_AR began at the beginning.
 
Thomas_AR's Avatar
 
Posts: 76
Karma: 10
Join Date: Jan 2015
Location: Buenos Aires
Device: Android
Quote:
Originally Posted by eschwartz View Post
Begin with the template fragment:
Code:
{series:'test($, strcat("SR - ", field("series")), field("authors")))'}
Thanks, i will check that out. I have to have a closer look
at the plugboard. I am no quiet sure for what to use it
For now i do this templates in the Device configuration.
Thomas_AR is offline   Reply With Quote
Old 03-08-2015, 10:51 AM   #4
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 12,663
Karma: 30811118
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Device configuration controls filenames, plugboards allow dynamically updating metadata fields.
One common use is to insert series into the title, so devices, which generally don't support series, show the title as e.g. "title (series, Book #)"
eschwartz is offline   Reply With Quote
Old 03-08-2015, 11:14 AM   #5
Thomas_AR
Connoisseur
Thomas_AR began at the beginning.
 
Thomas_AR's Avatar
 
Posts: 76
Karma: 10
Join Date: Jan 2015
Location: Buenos Aires
Device: Android
Quote:
Originally Posted by eschwartz View Post
Device configuration controls filenames, plugboards allow dynamically updating metadata fields.
One common use is to insert series into the title, so devices, which generally don't support series, show the title as e.g. "title (series, Book #)"
Thanks for the explanation. As i have an Android, so far no use for the plugboard.

Ah just one question:
I see that i can insert the(my) template in "Configure this device" and in "Preferences - Send book to devices". What is the difference?

Last edited by Thomas_AR; 03-08-2015 at 11:18 AM.
Thomas_AR is offline   Reply With Quote
Old 03-08-2015, 12:20 PM   #6
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 16,549
Karma: 7667666
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Astak Pocket Pro, K4NT,Galaxy Tab 2
Quote:
Originally Posted by Thomas_AR View Post
Thanks for the explanation. As i have an Android, so far no use for the plugboard.

Ah just one question:
I see that i can insert the(my) template in "Configure this device" and in "Preferences - Send book to devices". What is the difference?
Preferences becomes the default for NEW devices. Once a device has been used, you need to change at the device level
theducks is online now   Reply With Quote
Old 03-08-2015, 12:33 PM   #7
Thomas_AR
Connoisseur
Thomas_AR began at the beginning.
 
Thomas_AR's Avatar
 
Posts: 76
Karma: 10
Join Date: Jan 2015
Location: Buenos Aires
Device: Android
Thanks for all your kind help.

So, i think i nearly have it - nice clear folder structure.

{series:'test($, strcat("_", field('series'), " - ",field('authors')), field('authors'))'}/{series_index:0>4s| | - }{title} - {authors}

But there is one problem in case of series:
If there is only one author everything regarding file structure is perfect, but if i have various authors (i have series with about 10 different authors) i get different folders for the series and the different authors.

series - author 1
series - author 2
etc.

Is there a possibility in case there are various authors for one series to make one folder like:

"Series - Various"

or something similar?
But this is not so important, i can live without the authors string in the series folder name.

Thanks again for your patience.

Last edited by Thomas_AR; 03-08-2015 at 12:50 PM.
Thomas_AR is offline   Reply With Quote
Old 03-08-2015, 12:50 PM   #8
chaley
"chaley", not "charley"
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.
 
chaley's Avatar
 
Posts: 6,674
Karma: 1891006
Join Date: Jan 2010
Location: France
Device: Many android devices
As you are sending files to CC and wanting to use a rather complex folder structure for use with file managers, you should know about the path length restrictions. The wireless driver in calibre enforces a maximum file length of approximately 200 characters for a book file on your device. The limit comes from an attempt to ensure that a Windows machine can use MTP to see the files. If your template generates a name longer than allowed then each component of the name (the parts between / characters) will be truncated by removing characters out of the middle of the component until the path fits. If you have books with multiple authors and long titles, it is virtually guaranteed that the path on the device will not be what you expect.

You can ensure that the path names follow your rules within the limit by using a template that ensures that the components fit within acceptable lengths while being truncated using your rules. See the "shorten" template function.

BTW: eschwartz;s example has an extra parenthesis at the end. It should be
Code:
{series:'test($, strcat("SR - ", field("series")), field("authors"))'}
chaley is offline   Reply With Quote
Old 03-08-2015, 01:04 PM   #9
Thomas_AR
Connoisseur
Thomas_AR began at the beginning.
 
Thomas_AR's Avatar
 
Posts: 76
Karma: 10
Join Date: Jan 2015
Location: Buenos Aires
Device: Android
Hello chaley,
thanks and yes i am aware of the 200 character limitation.
Regarding the "extra parenthesis": I had to eliminate one of the three at the endto get his example to work, i got a syntax error with all 3 of them. Or do i miss something?

Last edited by Thomas_AR; 03-08-2015 at 01:10 PM.
Thomas_AR is offline   Reply With Quote
Old 03-08-2015, 01:09 PM   #10
chaley
"chaley", not "charley"
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.
 
chaley's Avatar
 
Posts: 6,674
Karma: 1891006
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by Thomas_AR View Post
Thanks for all your kind help.

So, i think i nearly have it - nice clear folder structure.

{series:'test($, strcat("_", field('series'), " - ",field('authors')), field('authors'))'}/{series_index:0>4s| | - }{title} - {authors}

But there is one problem in case of series:
If there is only one author everything regarding file structure is perfect, but if i have various authors (i have series with about 10 different authors) i get different folders for the series and the different authors.

series - author 1
series - author 2
etc.

Is there a possibility in case there are various authors for one series to make one folder like:

"Series - Various"

or something similar?
But this is not so important, i can live without the authors string in the series folder name.

Thanks again for your patience.
This would do it.
Code:
{series:'test($, strcat("_", field('series'), " - ", cmp(count(field("authors"), '&'), 2, field('authors'), 'various', 'various')), field('authors'))'}/{series_index:0>4s| | - }{title} - {authors}
However, you have reached the complexity point where I would use general program mode. The template in GPM is something like
Code:
program: 
	s = field('series');
	si=field('series_index');
	a = field('authors');
	t = field('title');
	short_author=cmp(count(a, '&'), 1, a, a, 'various');
	strcat(
		test(s, strcat("_", s, " - ", short_author), a),
	 	'/',
		finish_formatting(si, '0>4s', '', ' - '),
		t,
		' - ',
		a)

Last edited by chaley; 03-08-2015 at 01:12 PM.
chaley is offline   Reply With Quote
Old 03-08-2015, 01:12 PM   #11
chaley
"chaley", not "charley"
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.
 
chaley's Avatar
 
Posts: 6,674
Karma: 1891006
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by Thomas_AR View Post
Hello chaley,
thanks and yes i am aware of the 200 character limitation.
Regarding the "extra parenthesis": I had to eliminate one of the three at the end and had to change the " to ' in field("series")), field("authors") to get his example to work. Or do i miss something?
The parenthesis change you made is what I was saying. I don't know why you had to change the quotes. I didn't.
chaley is offline   Reply With Quote
Old 03-08-2015, 01:14 PM   #12
Thomas_AR
Connoisseur
Thomas_AR began at the beginning.
 
Thomas_AR's Avatar
 
Posts: 76
Karma: 10
Join Date: Jan 2015
Location: Buenos Aires
Device: Android
Thanks, i think with this i am happy.
Uh, something new again "template in GPM".
Will see how to do this and where

P.S.
Tried:
Code:
{series:'test($, strcat("_", field('series'), " - ", cmp(count(field("authors"), '&'), 2, field('authors'), 'various', 'various')), field('authors'))'}/{series_index:0>4s| | - }{title} - {authors}
Still got for each author a folder.
I think i leave it without the author in the serious folder

Last edited by Thomas_AR; 03-08-2015 at 01:40 PM.
Thomas_AR is offline   Reply With Quote
Old 03-08-2015, 01:15 PM   #13
Thomas_AR
Connoisseur
Thomas_AR began at the beginning.
 
Thomas_AR's Avatar
 
Posts: 76
Karma: 10
Join Date: Jan 2015
Location: Buenos Aires
Device: Android
Quote:
Originally Posted by chaley View Post
The parenthesis change you made is what I was saying. I don't know why you had to change the quotes. I didn't.
I went back to the " quotes and eliminated one ), working. Do not know what and why it happened.
Thomas_AR is offline   Reply With Quote
Old 03-08-2015, 01:24 PM   #14
chaley
"chaley", not "charley"
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.
 
chaley's Avatar
 
Posts: 6,674
Karma: 1891006
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by Thomas_AR View Post
Thanks, i think with this i am happy.
Uh, something new again "template in GPM".
Will see how to do this and where
GPM templates are documented here.

You can use a GPM template anywhere you can use a normal template. For example, you could paste the template I provided into the box where you put the Template Program Mode template you are using now.

There is a template test & development editor available via the "Template Tester" on the calibre books spreadsheet. I put the template tester onto the context menu (the right-click menu) so it is easily accessible for a given book.
chaley is offline   Reply With Quote
Old 03-08-2015, 01:33 PM   #15
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 12,663
Karma: 30811118
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
I would (and do) use a sublist to restrict "authors" to the first author, e.g. {authors:sublist(0,1,&)} -- or in GPM,
Code:
short_author = sublist(
    field('authors'),
    '0',
    '1',
    '&'
);

Last edited by eschwartz; 03-08-2015 at 01:40 PM.
eschwartz 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
Send to device - Template help Snow Sciles Library Management 12 05-26-2014 05:16 PM
Generic "Sending to Device" template not kicking in on Folder Device At_Libitum Library Management 2 11-01-2013 07:12 AM
Save to Device template HFC3 Library Management 6 07-08-2013 11:48 AM
Save template for sending books to Kindle 3 Eaglebeak60 Devices 2 02-14-2011 06:12 PM
Send to device template rockeh Calibre 6 08-17-2010 05:28 PM


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


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