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-07-2011, 06:02 PM   #1
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: 31,023
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Question Complex SaveTo pattern error

I just got around to trying this feature (been doing a pick from 2 patterns)

Code:
{series:switch("","00noseries"/{author_sort[0]}_authors/{authors}/{title}_{id}_{title}-{authors},{series[0]}-series/{series}/{series_index:0>2s}-{title}_{id}_{authors})}
When I save a series I get the second (else) part.
When the series is blank, the attached file (OPF part of the pair. Avoiding copyright issues ) name is generated (no folder path,either)
BTW,I tries without the quotes around 00noseries first.

did I miss something?
TNX

Last edited by theducks; 08-16-2012 at 08:30 PM.
theducks is offline   Reply With Quote
Old 03-08-2011, 04:42 AM   #2
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: 12,421
Karma: 8012664
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by theducks View Post
I just got around to trying this feature (been doing a pick from 2 patterns)

Code:
{series:switch("","00noseries"/{author_sort[0]}_authors/{authors}/{title}_{id}_{title}-{authors},{series[0]}-series/{series}/{series_index:0>2s}-{title}_{id}_{authors})}
When I save a series I get the second (else) part.
When the series is blank, the attached file (OPF part of the pair. Avoiding copyright issues ) name is generated (no folder path,either)
BTW,I tries without the quotes around 00noseries first.

did I miss something?
TNX
You missed a lot.

The template language supports three modes: single function, template program, and general program. Your template is using single function syntax, which (unfortunately for your example) does not support quoted strings or non-constant arguments (arguments that require further evaluation). In addition, no mode supports implicit string concatenation, which you are using after "00noseries". Finally, the regular expression "" (in the switch) will look for literal 2 quotes and match anything, which isn't what you want. You would need something like ^$, or "^$" in one of the other two modes.

You could use template program mode and fix all of this, but with something as complex as you have I would instead suggest that you use general program mode. In that mode, the program would be:
Code:
program: 
test(	field('series'), 
	template("{series[0]}-series/{series}/{series_index:0>2s}-{title}_{id}_{authors}"),
	template("00noseries/{author_sort[0]}_authors/{authors}/{title}_{id}_{title}-{authors}")
)
For completeness, note that the although the above program works, it prints some exception messages. The reason is that the second argument to test, the first template line, is evaluated but not used. In that context, {series[0]} is invalid. A cleaner implementation, one with no exceptions, would be:
Code:
program: 
test(	field('series'), 
	strcat(
		substr(field('series'), 0, 1),
		template("-series/{series}/{series_index:0>2s}-{title}_{id}_{authors}")
	),
	template("00noseries/{author_sort[0]}_authors/{authors}/{title}_{id}_{title}-{authors}")
)

Last edited by chaley; 03-08-2011 at 10:56 AM.
chaley is offline   Reply With Quote
Advert
Old 03-08-2011, 09:36 AM   #3
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: 31,023
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Wow!

I can put all that (the last) into a 'save to disk' template?
theducks is offline   Reply With Quote
Old 03-08-2011, 09:48 AM   #4
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: 31,023
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Thumbs up Works perfectly

Answered my own question by testing

theducks is offline   Reply With Quote
Old 03-08-2011, 10:55 AM   #5
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: 12,421
Karma: 8012664
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by theducks View Post
Answered my own question by testing
:
Good. And you are welcome.

Out of curiosity, why do you have the title in the name twice in the "00noseries" template?
chaley is offline   Reply With Quote
Advert
Old 03-08-2011, 11:20 AM   #6
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: 31,023
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by chaley View Post
Good. And you are welcome.

Out of curiosity, why do you have the title in the name twice in the "00noseries" template?
GIGO
That was an error I corrected long ago in the actual template (when th underscore used to be a / and failed to correct in my 'Notes log' that I used for the message.
+fixed+
theducks is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sewing pattern for e-readers! strawhatbrat Deals and Resources (No Self-Promotion or Affiliate Links) 11 12-02-2010 09:23 PM
header removal fails, even though test identifies the pattern hpep Calibre 2 08-09-2010 12:40 PM
Virus pattern match upon connecting Astak Pocket Pro to my computer Xochipilli2012 Astak EZReader 6 03-04-2010 02:24 AM
Literary Pattern Matching kennyc News 5 12-16-2009 03:12 PM
How do I specify TOC pattern? PaulChernoch Calibre 5 10-10-2009 01:18 AM


All times are GMT -4. The time now is 11:07 AM.


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