| 
			
			 | 
		#1 | 
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129 
				Karma: 5754 
				Join Date: Jan 2012 
				Location: South Africa 
				
				
				Device: Kindle 4 
				
				
				 | 
	
	
	
		
		
			
			 
				
				More help needed: regex for add books
			 
			
			
			There are 2 questions, question 2 being the ideal situation.. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Question 1: If the book has no series, the file format is author - title If it does have series, the current format is author - [series] [series_number] title If I use this regex (?P<author>.+) - \[(?P<series>.+)\] \[(?P<series_index>.+)\] (?P<title>[^_]+) it works if there is a series, but not of there isn't. How do I fix this? Question 2: I would prefer file format to be author - [series series_number] title But what if the series name is say Oceans 11, and the book is number 3 in the series. We'd have author - [Oceans 11 03] - title This requires a complicated regex, which is entirely beyond me.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#2 | 
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,751 
				Karma: 2667650 
				Join Date: Jul 2012 
				
				
				
				Device: Android, Nook Simple Touch, Nook Color, ..., Glo 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			And you want this for adding books or saving to disk? 
		
	
		
		
		
		
		
		
		
		
		
		
	
	There should be something you can do with the bracket as the trigger, but I'm sleepy and not of very much use atm. So I'll check back tomorrow and see if anyone else beat me to it.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#3 | 
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129 
				Karma: 5754 
				Join Date: Jan 2012 
				Location: South Africa 
				
				
				Device: Kindle 4 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			This is for adding - got saving to disk cracked (thanks to your inspiration.) have a good sleep.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#4 | 
| 
			
			
			
			 Guru 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 644 
				Karma: 1242364 
				Join Date: May 2009 
				Location: The Right Coast 
				
				
				Device: PC (Calibre), Nexus 7 2013 (Moon+ Pro), HTC HD2/Leo (Freda) 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Ok, it's late and I'm not sure I'm exactly answering your question... but take a look at my post in the Tyrannosaurus Regex topic.  
		
	
		
		
		
		
		
		
		
		
		
		
		
			While the topic is very old, the complex regex works extremely well and should do what you want. It has the added benefit of having a cursory explanation of which clump of regex is doing what. It doesn't (unfortunately) offer a fully detailed explanation as it's the combined effort of multiple people - I was simply the person to string together the bits and pieces. The only catch that I see immediately is that it depends on " - " (space dash space) being the delimiter between author/series info and series info/title. This is mandatory to differentiate the series info out from the rest - particularly in an "Oceans 11" type of series name situation. I have seen simpler regex variants that can produce somewhat similar results - but not exactly similar. One difference I remember dealt with having L33t5p34k (leetspeak) within the mix. But all of this is noted in the topic. (Just in case... You might be able to use a bulk filename utility to add " - " if needed to any existing files. Check any freeware website for viable choices. Rename-It! is my main tool on Windows XP & 7. Haven't tried it on Win8.) Last edited by Sabardeyn; 06-16-2013 at 07:57 AM. Reason: Additional comment.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#5 | 
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129 
				Karma: 5754 
				Join Date: Jan 2012 
				Location: South Africa 
				
				
				Device: Kindle 4 
				
				
				 | 
	
	
	
		
		
			
			 
			
			Been using Bulk Rename Utility for years - excellent piece of software. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	The regex works well, even handling the Oceans 11 scenario.   Thanks.I'll print out the regex and use coloured highlighters to mark off the sections and see if I can change it to use my bracket system. If successful, I will add it to that thread.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#6 | 
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,751 
				Karma: 2667650 
				Join Date: Jul 2012 
				
				
				
				Device: Android, Nook Simple Touch, Nook Color, ..., Glo 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			OK..checking in after a long day (sorry so late) but let me know if you never found what you needed and I'll try to be of useful assistance in the light of day  
		
	
		
		
		
		
		
		
		
		
		
		
	
	 
		 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#7 | |
| 
			
			
			
			 US Navy, Retired 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,897 
				Karma: 13806776 
				Join Date: Feb 2009 
				Location: North Carolina 
				
				
				Device: Icarus Illumina XL HD, Kindle PaperWhite SE 11th Gen 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#8 | 
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129 
				Karma: 5754 
				Join Date: Jan 2012 
				Location: South Africa 
				
				
				Device: Kindle 4 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Thanks for the help everyone. The Quick Preferences plug-in is ideal for me - can have different filename styles without having to climb in with Bulk Rename Utility. The Swap Author Names is also useful. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Does anybody have an opinion on file-names with underscores instead of spaces, or is that best solved with Bulk Rename?  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#9 | 
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129 
				Karma: 5754 
				Join Date: Jan 2012 
				Location: South Africa 
				
				
				Device: Kindle 4 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			If anybody finds this useful: 
		
	
		
		
		
		
		
		
		
		
		
		
	
	This regex will accept both of these formats: author - title author - [series series_index] title Regex: Code: 
	^(?P<author>((?!\s-\s).)+)\s-\s(?:(?:\[\s*)?(?P<series>.+)\s(?P<series_index>[\d\.]+)(?:\s*\])?\s)?(?P<title>[^(]+)(?:\(.*\))?  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#10 | 
| 
			
			
			
			 Guru 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 644 
				Karma: 1242364 
				Join Date: May 2009 
				Location: The Right Coast 
				
				
				Device: PC (Calibre), Nexus 7 2013 (Moon+ Pro), HTC HD2/Leo (Freda) 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			I'm glad to learn that my suggestion was helpful to you. And better still that you were able to alter it to fit your needs and re-posted it. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	BTW, a forum related tip: Found a gem of wisdom in a thread but you cannot make use of it this instant? Use the Thread Tools>Subscribe to this Thread drop down menu option (top of page) to keep the thread title and link in your User Control Panel. If used sparingly, it's a great way to "bookmark" important threads.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#11 | 
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129 
				Karma: 5754 
				Join Date: Jan 2012 
				Location: South Africa 
				
				
				Device: Kindle 4 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Good tip.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#12 | 
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,751 
				Karma: 2667650 
				Join Date: Jul 2012 
				
				
				
				Device: Android, Nook Simple Touch, Nook Color, ..., Glo 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			glad you found what you needed!
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
![]()  | 
            
        
    
| Tags | 
| add book, regex | 
            
  | 
    
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Help: regex for add books | macnab69 | Library Management | 4 | 06-16-2013 02:53 AM | 
| My RegEx works in Test but not for Add Books | kanigetts | Library Management | 11 | 09-18-2012 03:59 AM | 
| Want RegEx to add books to Calibre | huon | Library Management | 0 | 02-02-2012 01:52 AM | 
| Add Books - Regex Help Please | nynaevelan | Calibre | 2 | 08-16-2011 02:30 PM | 
| understandng the sample add books regex | cybmole | Library Management | 11 | 03-02-2011 07:08 AM |