View Single Post
Old 01-10-2014, 04:18 AM   #466
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: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Gary_M_Mugford View Post
Gawd, does THIS feel familiar. Me pie in the skying and you coming to the battle.
Quote:
Okay, since YOU ASKED .... I'm faced with this situation. I add a rather large number of books. I then select the newly added ones and change the new books to have an Uncat value in the my #gmtags column. It's not a complex column, just one that allows for my small tag sub-set, Mysteries, Thrillers, SF, NF, Sports, Biographies, Sports Biographies, Bridge, Writing and Young Adult. Then, I ctrl-D and download the metadata from the internet. I then run a series of saved searches that looks for #gmtags=Uncat added to a series of search terms in a bracketed OR clause for the tags field. One that covers, for the most part, each of the gmtags categories. After it finds the uncategorized books that fit, I select all and go into group edit. I check off delete all gmtags and then add that particular gmtag. Click OK and the books all disappear. I then move on to the next saved search. Repeat rinse cycle.

...

That's WHAT I am doing. I would like to shorten the steps down to one really smart super search (that would change the other column), because wrapping it up IN a created column definition might slow things down during normal use of the library I have created in Calibre. I'm sure there are bigger libraries out there. But given the inclusion of academic papers and my own writings and acquired books, mine is sizable.
Given that you don't want to use a composite custom column (what you called a created column), I don't see any better way to do it than you are already using. The difficulty: you really want some form of scripting or automation that permits you to change values in "normal" columns on demand based on some conditions. Calibre does not have a embedded scripting language that can do this. Composite columns come close, but they are computed on every use (display) and not on demand as you want.

You could do what you want using calibre's command line tools as a scripting language, but it is probably not worth the effort. You would write a program that creates scripts. It would do something like:
Search for books with Uncat. For each book found:
1) Get the tags for that book
2) Analyze the tags (this is the interesting part. Depending on the language, it could be easy or hard.)
3) produce a calibre command line "script" that sets #gmtags to the appropriate value
4) run that produced script

If you feel like writing in python, another way to do it would be to write a program against calibre's internal db API that does the analysis and the updating. This would run orders of magnitude faster, but requires much more specialized knowledge.
chaley is offline   Reply With Quote