| 
			
			 | 
		#571 | |
| 
			
			
			
			 Connoisseur 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 77 
				Karma: 3090 
				Join Date: Apr 2013 
				Location: California 
				
				
				Device: Kobo Aura One, Kobo Aura H20,Kindle PW1 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Also the regex was exactly what I was looking for which just proves I was correct in asking in the first place. I originally thought it was an un-modifiable field other then manually entering in something or downloading the data. I am very grateful for all your help, a couple of days ago my laptop died and then by backup was corrupted, so I lost everything I had with the exception to what I had stored in the cloud and felt that this was the best time to recreate stuff that I have been wanting to solve for a little while. So new Laptop and backup drive and calibre is at the point to where I can just sit back and enjoy it. I do have one small thing that is eluding if you wouldn't mind once again helping me with. In Metadata Plugboards I have template set up for: Epub and Any Device Source template: {title} - {series}{series_index:0>3s| [|] Destination Field: title When dealing with series it works perfectly, but when dealing with a book that is not part of a series I have a dash leftover Example: Ken Follets Book: Edge of Eternity becomes: Edge of Eternity - The Century Trilogy [03] Cottam, F. G. Book: The Lazarus Prophecy becomes: The Lazarus Prophecy - How can I get it to drop the "-" at the end of the title on a book with no series? Yet keep it for series? Thank you very much eschwartz!  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#572 | 
| 
			
			
			
			 Ex-Helpdesk Junkie 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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) 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Use:  
		
	
		
		
		
		
		
		
		
		
		
		
		
			Code: 
	{title}{series:| - |}{series_index:0>3s| [|]}
Everything after the ":" is a modifier. The "|stuff|stuff" are prefixes and suffixes for the parent template (in this case, series) -- as you can see, you already have one for series_index. This allows for making stuff dependent on the parent template existing. So. I simply moved the space and dash to be dependent on the series field not being empty. Last edited by eschwartz; 09-18-2014 at 11:45 PM.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#573 | ||
| 
			
			
			
			 Ex-Helpdesk Junkie 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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: 
	
 ![]() Quote: 
	
  
		 | 
||
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#574 | |
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525 
				Karma: 8065948 
				Join Date: Jan 2010 
				Location: Notts, England 
				
				
				Device: Kobo Libra 2 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Code: 
	s_index = finish_formatting(field('series_index'), '.2f', ' [', ']'))
 | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#575 | 
| 
			
			
			
			 null operator (he/him) 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,018 
				Karma: 30277294 
				Join Date: Mar 2012 
				Location: Sydney Australia 
				
				
				Device: none 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			If I want  
		
	
		
		
		
		
		
		
		
		
		
		
	
	Code: 
	if (tags:count(,) > 5)
     return "too many" 
else
     return ""
endif
Code: 
	{cmp(tags:count(','), 5, "", "", "too many")}
 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#576 | |
| 
			
			
			
			 Zealot 
			
			![]() Posts: 116 
				Karma: 10 
				Join Date: Jun 2011 
				Location: Stockport, UK 
				
				
				Device: ipad, iphone, kindle 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 I changed formulas to stripped = re(field('series'), '^(A|The|An)\s+', ''); shortened = shorten(stripped, 8, '-' ,6); initials = re(stripped, '[\s]?([^\s]{1,3})[^\s]+(\s|$)', '\1'); But summats wrong Worlds Without End becomes WorWitEn Missing "d"? Also is it poss to have it as Wor-Wit-End Also, is it feasible to add in the code we rejigged when doing series with fractions? you had a prog to decide which formula to use to reformat the series link properly depending on size of highest number and presence of fractions :-)  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#577 | |
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525 
				Karma: 8065948 
				Join Date: Jan 2010 
				Location: Notts, England 
				
				
				Device: Kobo Libra 2 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Code: 
	{ fieldKey : format/function | prefix | suffix }
The second is template program mode (TPM), and has the approximate syntax Code: 
	{ field name :'possibly nested functions'}
The third is general program mode (GPM). This mode has a more "classic" program style. It is considered as one template, where the other two can be chains of templates. GPM has no restrictions on characters used. It is the most expressive of all the three. Unfortunately your example uses nested functions but does not use TPM syntax. It also uses attribute-like referencing (tags:count) which doesn't exist in the language. The equivalent in TPM is Code: 
	{tags:'cmp(count($, ','), 5, "", "", "too many")'}
Code: 
	program: 
	cmp(
		count(
			field('tags'), 
			','), 
		5, 
		"", 
		"", 
		"too many")
 | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#578 | 
| 
			
			
			
			 Zealot 
			
			![]() Posts: 116 
				Karma: 10 
				Join Date: Jun 2011 
				Location: Stockport, UK 
				
				
				Device: ipad, iphone, kindle 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Whilst I am asking - how would I get a column of the length of the title - I have some that have ended up massively long and I want to quickly find them and edit them :-)
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#579 | 
| 
			
			
			
			 Zealot 
			
			![]() Posts: 116 
				Karma: 10 
				Join Date: Jun 2011 
				Location: Stockport, UK 
				
				
				Device: ipad, iphone, kindle 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Actually its not handling and words 3 or less properly - loses last letter??
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#580 | ||
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525 
				Karma: 8065948 
				Join Date: Jan 2010 
				Location: Notts, England 
				
				
				Device: Kobo Libra 2 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Code: 
	{title:strlen()}
Quote: 
	
 Code: 
	initials = re(stripped, '[\s]?([^\s]{1,3})[^\s]*(\s|$)', '\1');
Code: 
	initials = re(list_re(stripped, ' ', '[\s]?([^\s]{1,3})[^\s]*(\s|$)', '\1'), ' ', '-');
 | 
||
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#581 | |
| 
			
			
			
			 Ex-Helpdesk Junkie 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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: 
	
 ![]() I already know about it, though. I do use it when in general program mode. EDIT:   It came true sooner than I thought. Look at the recycled s_index below.
		Last edited by eschwartz; 09-19-2014 at 12:54 PM.  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#582 | |||
| 
			
			
			
			 Ex-Helpdesk Junkie 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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: 
	
 The previous template assumed only the first letter would be captured, and matched the following letters outside the capture. But it required there to be letters outside, under the assumption that any word would have at least two letters. So at least one letter at the end would not be included. hence chaley's fix. Quote: 
	
   Well, list_re_group() specifically. I'm sure they will eventually click into place though.Thanks, and thank you for all these recent extensions to template programming! They will no doubt make things easier as soon as I get the hang of them. ![]() Quote: 
	
 PHP Code: 
	
			
	Ah, it's easy. Just replace s_index. PHP Code: 
	
			
	![]() Using the second fix, to get "Wor-Wit-End" style. Last edited by eschwartz; 09-19-2014 at 01:07 PM. Reason: remembered to use chaley's fix.  | 
|||
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#583 | 
| 
			
			
			
			 Zealot 
			
			![]() Posts: 116 
				Karma: 10 
				Join Date: Jun 2011 
				Location: Stockport, UK 
				
				
				Device: ipad, iphone, kindle 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Nearly there - somethings wrong with 
		
	
		
		
		
		
		
		
		
		
		
		
	
	#complex_series If I cange it to series_index it works, but seems to return __01.00 for even simple 1,2,3 series numbers also shows as [ [__01.00] ] Can we replace _ with space as its in program mode?  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#584 | ||
| 
			
			
			
			 Ex-Helpdesk Junkie 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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) 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			What exactly is wrong with it? I cannot think why it wouldn't work, especially as it seemed to work before? 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Quote: 
	
 Quote: 
	
  | 
||
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#585 | 
| 
			
			
			
			 Zealot 
			
			![]() Posts: 116 
				Karma: 10 
				Join Date: Jun 2011 
				Location: Stockport, UK 
				
				
				Device: ipad, iphone, kindle 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			My bad re comples_series - I had forgotten we went for a manual Y/N re complex series 
		
	
		
		
		
		
		
		
		
		
		
		
	
	I was thinking of the code https://www.mobileread.com/forums/sho...&postcount=552 To set the correct format. I thought the code before the latest tweak took care of leading spaces later on - yours adds brackets and then original adds 2 more brackets later on :-)  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
![]()  | 
            
        
            
| Tags | 
| custom column, tag, tags | 
            
  | 
    
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Should composite columns appear in Grouped Searches? | ownedbycats | Library Management | 3 | 02-13-2021 04:43 PM | 
| Having problems with composite columns and save/send templates | Trel | Calibre | 4 | 09-26-2016 04:21 PM | 
| Tooltips for narrow columns | theducks | Library Management | 7 | 03-16-2015 11:58 PM | 
| Techniques to use plugboards, custom columns and templates | kovidgoyal | Library Management | 0 | 01-26-2011 05:21 PM |