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 03-05-2016, 03:13 PM   #1
MontyJ
Addict
MontyJ began at the beginning.
 
Posts: 224
Karma: 10
Join Date: Jul 2012
Device: Kindle
Question Save to Disk templates on per library basis?

I use 3 different "Save to Disk" setup templates for my various libraries because they each have specialized content that requires a unique save format. I have looked for a way to have each library maintain its own set of default templates but can't see a way to do it.

Presently I keep those templates in a plain text file, labeled so I know which goes to which. Then I use the drop down selection in a given library and select the correct one.

If there isn't a way to do this currently, I would like to suggest that be considered as a future added feature. I switch libraries constantly and this would sure same me some extra 'lookup' efforts!

Monty
MontyJ is offline   Reply With Quote
Old 03-05-2016, 05:50 PM   #2
theducks
Well trained by Cats
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: 30,957
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
It is doable (my coding skils are not quite up to this) in Program Mode

Take a look at http://manual.calibre-ebook.com/template_lang.html


class calibre.utils.formatter_functions.BuiltinCurrentLi braryName[source]

You should be able to use:
current_library_name() – return the last name on the path to the current calibre library. This function can be called in template program mode using the template “{:’current_library_name()’}”.
With a switch(val, pattern, value, pattern, value, ..., else_value)
theducks is online now   Reply With Quote
Advert
Old 03-05-2016, 06:59 PM   #3
MontyJ
Addict
MontyJ began at the beginning.
 
Posts: 224
Karma: 10
Join Date: Jul 2012
Device: Kindle
theducks,

Thanks...my eyes are glazing over a bit, as my coding skills are mostly non-existent. But, you gave me something that might work, so I will play with it and see what I can come up with!

Monty
MontyJ is offline   Reply With Quote
Old 03-06-2016, 01:18 AM   #4
eschwartz
Ex-Helpdesk Junkie
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: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
The problem is that save-to-disk works like the device drivers, and is a global preference (it is stored in your config data, not in the library database).

As theducks said, current_library_name() is your friend -- but if you are unsure how to use it, feel free to ask and we can write a suitable template for you.
Just tell us what you want to see.

Note: There is a dedicated help sticky in this subforum with various tips and things that people have asked for in the past.
eschwartz is offline   Reply With Quote
Old 03-06-2016, 01:21 AM   #5
eschwartz
Ex-Helpdesk Junkie
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: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
The basic idea looks like this:

Code:
program:

switch(
    current_library_name(),
    'libraryname1',
    template1,
    'libraryname2',
    template2,
    'libraryname3',
    template3,
    fallback_template
)
eschwartz is offline   Reply With Quote
Advert
Old 03-06-2016, 10:13 AM   #6
MontyJ
Addict
MontyJ began at the beginning.
 
Posts: 224
Karma: 10
Join Date: Jul 2012
Device: Kindle
Quote:
Originally Posted by eschwartz View Post
The basic idea looks like this:

Code:
program:

switch(
    current_library_name(),
    'libraryname1',
    template1,
    'libraryname2',
    template2,
    'libraryname3',
    template3,
    fallback_template
)
Thanks for this! I need to learn how to do this, at least in some minimal form. Let me see how far I get; I will probably be back with some noob type questions, LoL.
MontyJ is offline   Reply With Quote
Old 03-06-2016, 11:32 AM   #7
theducks
Well trained by Cats
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: 30,957
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
That will be new template (after you substitute the Library names and the corresponding templates)
do pay attention to Library name Case. it must match reality
theducks is online now   Reply With Quote
Old 03-07-2016, 12:57 PM   #8
fidvo
Addict
fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.
 
Posts: 309
Karma: 1645952
Join Date: Jun 2012
Device: none
FWIW, here is my Save to Disk template:

Code:
program:

switch(current_library_name(),
  'Library - Main',
  template('{#path:re(\.,/)}/{series_index:0>3s||_}{#subseries}{#subseries_index:0>3s||_}{title}'),
  'Library - Special',
  template('{#path:re(\.,/)}/{series_index:0>3s||_}{title}'),
  'Library - In Progress',
  template('{author_sort}/{series}/{series_index:0>3s}_{title}'),
  template('{#path:re(\.,/)}/{#seriesid:re(\.,/)}{#titleid:re(\.,/)}'))
Note that "path" is a custom field I set up, not the path to the file. (In hindsight I should have named it something else)
fidvo is offline   Reply With Quote
Old 03-07-2016, 01:31 PM   #9
eschwartz
Ex-Helpdesk Junkie
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: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by fidvo View Post
FWIW, here is my Save to Disk template:

Code:
program:

switch(current_library_name(),
  'Library - Main',
  template('{#path:re(\.,/)}/{series_index:0>3s||_}{#subseries}{#subseries_index:0>3s||_}{title}'),
  'Library - Special',
  template('{#path:re(\.,/)}/{series_index:0>3s||_}{title}'),
  'Library - In Progress',
  template('{author_sort}/{series}/{series_index:0>3s}_{title}'),
  template('{#path:re(\.,/)}/{#seriesid:re(\.,/)}{#titleid:re(\.,/)}'))
Note that "path" is a custom field I set up, not the path to the file. (In hindsight I should have named it something else)
Invoking templates inside GPM is ugly (and slower) why not use this?

Code:
program:

# Initialize repetitive and/or complicated values for later use.
path = re(
	field('#path'),
	'\.',
	'/'
);
seriesid = re(
	field('#seriesid'),
	'\.',
	'/'
);
titleid = re(
	field('#titleid'),
	'\.',
	'/'
);

sidx = finish_formatting(
	field('series_index'),
	'0>3s',
	'',
	'_'
);
subsidx = finish_formatting(
	field('#subseries_index'),
	'0>3s',
	'',
	'_'
);

# Compute final return value.
switch(
	current_library_name(),
	'Library - Main',
	strcat(
		path, '/', sidx, field('#subseries'), subsidx, field('title')
	),
	'Library - Special',
	strcat(
		path, '/', sidx, field('title')
	),
	'Library - In Progress',
	strcat(
		field('author_sort'), '/', field('series'), '/', sidx, field('title')
	),
	strcat(
		path, '/', seriesid, titleid
	)
)
eschwartz is offline   Reply With Quote
Old 03-07-2016, 04:24 PM   #10
fidvo
Addict
fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.
 
Posts: 309
Karma: 1645952
Join Date: Jun 2012
Device: none
Quote:
Originally Posted by eschwartz View Post
Invoking templates inside GPM is ugly (and slower) why not use this?

Code:
program:

# Initialize repetitive and/or complicated values for later use.
path = re(
	field('#path'),
	'\.',
	'/'
);
seriesid = re(
	field('#seriesid'),
	'\.',
	'/'
);
titleid = re(
	field('#titleid'),
	'\.',
	'/'
);

sidx = finish_formatting(
	field('series_index'),
	'0>3s',
	'',
	'_'
);
subsidx = finish_formatting(
	field('#subseries_index'),
	'0>3s',
	'',
	'_'
);

# Compute final return value.
switch(
	current_library_name(),
	'Library - Main',
	strcat(
		path, '/', sidx, field('#subseries'), subsidx, field('title')
	),
	'Library - Special',
	strcat(
		path, '/', sidx, field('title')
	),
	'Library - In Progress',
	strcat(
		field('author_sort'), '/', field('series'), '/', sidx, field('title')
	),
	strcat(
		path, '/', seriesid, titleid
	)
)
You're right; that does look a lot cleaner, especially since I tend to use similar custom fields in all my libraries, so setting those values outside the main code block makes sense.

I'll have to give this a try.

fidvo is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reimport same library in Calibre (without Save to Disk)? rebl Library Management 9 06-11-2015 08:53 PM
Multiple save to disk templates? fidvo Library Management 5 03-10-2014 05:38 PM
plugin for favorite save to disk templates gabby98 Plugins 3 07-03-2013 01:35 PM
How to remove unwanted Save-to-disk templates alexmobile Calibre 5 02-22-2012 05:54 AM
Confused.. Difference between a Calibre Library & Save to Disk ipsofacto Library Management 5 01-05-2012 09:46 AM


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


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