| 
			
			 | 
		#1 | 
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112 
				Karma: 53342 
				Join Date: Jun 2013 
				
				
				
				Device: Sony PRS-600 
				
				
				 | 
	
	
	
		
		
			
			 
				
				calibredb 'merge'
			 
			
			
			Is there a way to have calibredb use the 'merge' action I use via the GUI? This not the same as adding a format. 
		
	
		
		
		
		
		
		
		
		
		
		
		
			I am cleaning up a few libraries I have integrated. I have a reliable identifier I can use to identify duplicates (CRC,extension,filesize) but other associated information such tags and tag-like fields.. These are bitwise-identical files, but I want to aggregate the supplementary information. What I'd like to do is write a script that will examine all sets of titles with the same unique key, and where the titles and authors match, merge them into a single entry. (I'll want to examine where these things differ to see which ones I prefer, so I'll still need to handle these ones manually.) I could make my script a little more sophisticated, of course, and handle the aggregation myself via set_metadata... but if it's already built-in, I'd rather do that. It's less work for me, and much more importantly, less prone to error. Last edited by kjdavies; 09-30-2023 at 01:27 PM. Reason: expand 'handle aggregation' description  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#2 | 
| 
			
			
			
			 Well trained by Cats 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,267 
				Karma: 61916422 
				Join Date: Aug 2009 
				Location: The Central Coast of California 
				
				
				Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Does calibredb --automerge, -m  work? 
		
	
		
		
		
		
		
		
		
		
		
		
	
	If books with similar titles and authors are found, merge the incoming formats (files) automatically into existing book records. A value of "ignore" means duplicate formats are discarded. A value of "overwrite" means duplicate formats in the library are overwritten with the newly added files. A value of "new_record" means duplicate formats are placed into a new book record.   the number in the containing Folder is the books {ID} if that helps
		 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#3 | |
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112 
				Karma: 53342 
				Join Date: Jun 2013 
				
				
				
				Device: Sony PRS-600 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 I'm thinking of a command something like Code: 
	calibredb merge id1 id2 id3  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#4 | |
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,216 
				Karma: 1995558 
				Join Date: Aug 2015 
				
				
				
				Device: Kindle 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 
 Notes: 
  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#5 | |
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112 
				Karma: 53342 
				Join Date: Jun 2013 
				
				
				
				Device: Sony PRS-600 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Can it be smart enough to also require that the titles match? Within a group I don't always have the titles match and would like to be able to pick which ones I want. (Yes, I realize I might be more or less unique in my need here...)  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#6 | |
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,216 
				Karma: 1995558 
				Join Date: Aug 2015 
				
				
				
				Device: Kindle 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Code: 
	not tag:"=exempt_unique" Last edited by capink; 09-30-2023 at 05:08 PM.  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#7 | |
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112 
				Karma: 53342 
				Join Date: Jun 2013 
				
				
				
				Device: Sony PRS-600 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#8 | |
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,216 
				Karma: 1995558 
				Join Date: Aug 2015 
				
				
				
				Device: Kindle 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Code: 
	not tag:"=exempt_unique"  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#9 | 
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			No there's no CLI interface for merging metadata.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#10 | 
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112 
				Karma: 53342 
				Join Date: Jun 2013 
				
				
				
				Device: Sony PRS-600 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Thanks Kovid, I was pretty sure. The documentation didn't mention it. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Is it worth submitting an enhancement request? I'm thinking the semantics would be something like Code: 
	calibredb merge [options] id1 id2 [... idN] 
  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#11 | 
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Not unless you are willing to implement it as well  
		
	
		
		
		
		
		
		
		
		
		
		
	
	 
		 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#12 | 
| 
			
			
			
			 Zealot 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 112 
				Karma: 53342 
				Join Date: Jun 2013 
				
				
				
				Device: Sony PRS-600 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			If I had the knowledge. Python is probably one of my weakest languages. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	I mean, LISP is lower (I've done some work with Schema via DSSSL... 20+ years ago) and I don't even admit to having seen COBOL, but of languages in common use today, Python is probably one of my weakest.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#13 | 
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525 
				Karma: 8065948 
				Join Date: Jan 2010 
				Location: Notts, England 
				
				
				Device: Kobo Libra 2 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			@kovid: I looked at the merge_metadata() method in the edit_metadata action. It is very self contained. I copied it to a python template and ran it with almost no changes. Metadata from my test books was merged. Of course it doesn't do anything with formats and doesn't delete any books. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	If I move it from the GUI to ebook.metadata.book then it could be used in scripts executed with 'calibre-debug -e' as well as be used by some eventual command line utility (that I am not volunteering to write). A stub must remain in edit_metadata to pass the db to the moved method. I could do the same thing with merge_data_files(), but I don't think it is necessary. The only thing is does is call the db api merge_extra_files() method. Is this OK with you?  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#14 | |
| 
			
			
			
			 Custom User Title 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,359 
				Karma: 79528341 
				Join Date: Oct 2018 
				Location: Canada 
				
				
				Device: Kobo Libra H2O, formerly Aura HD 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Spoiler: 
 
		 | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#15 | 
| 
			
			
			
			 creator of calibre 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609 
				Karma: 28549044 
				Join Date: Oct 2006 
				Location: Mumbai, India 
				
				
				Device: Various 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			@charles: Yes that's fine.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
![]()  | 
            
        
            
| Tags | 
| calibredb, merge | 
            
  | 
    
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Installer for calibredb only? | Freakeao | Calibre | 3 | 12-09-2020 10:19 PM | 
| Merge books, how to select FIRST book or MERGE metadata? | rboatright | Library Management | 11 | 08-20-2016 12:01 PM | 
| commandline calibredb | Divingduck | Calibre | 2 | 07-31-2014 06:18 AM | 
| calibredb | iomari | Calibre | 6 | 10-10-2011 09:35 AM | 
| Merge feature request (different merge) | Tarran | Calibre | 1 | 05-24-2010 11:57 AM |