Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 03-17-2011, 10:51 AM   #1
mobichuck
Junior Member
mobichuck began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 2
Equality searches via the calibredb 'list' option

I'm working on some scripting glue to help me maintain my library, and running into some problems automating Calibre via the calibredb command-line program.

I'm wanting to implement equality (instead of the default 'contains') searching via 'calibredb list' (using -s), but I can't get it to work like I think it should.

I have two books, "The Twins", and "Time of the Twins".

In the Calibre GUI, if I enter this search criteria:

Code:
title:"=The Twins"
I get what I would expect: the single book that exactly matches "The Twins", and "Time of the Twins" is left out.

But when I try and do this via the command-line, like so:

Code:
calibredb list -s title:"=The Twins"
I get NO results back. If I remove the equality indicator, it returns BOTH "The Twins" and "Time of the Twins", which isn't what I want. Ie:

Code:
calibredb list -s title:"The Twins"
works, but is a 'contains' search.


Can anybody tell me what I might be doing incorrectly?

FWIW: I'm trying to see if a book already exists; if it does, I want to get the ID. I have the exact title and author available for my search.
mobichuck is offline   Reply With Quote
Old 03-17-2011, 11:21 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 26,154
Karma: 5381911
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You need to use proper command line escaping

Code:
calibredb list -s 'title:"=The Twins"'
kovidgoyal is offline   Reply With Quote
 
Enthusiast
Old 03-17-2011, 11:31 AM   #3
mobichuck
Junior Member
mobichuck began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 2
Quote:
Originally Posted by kovidgoyal View Post
You need to use proper command line escaping

Code:
calibredb list -s 'title:"=The Twins"'
I'm so sorry; I meant to indicate that I actually did try this (and many other permutations of single-quotes, double-quotes, double-double-quotes, double-single quotes...)

Wrapping the entire thing in single-quotes (I've also tried the 'backtick') gives me zero results (copy and paste the above line from Kovid):

Code:
C:\Program Files\Calibre2>calibredb list -s 'title:"=The Twins"'
id title authors
If I remove the "=" but leave the single-quotes, I still get nothing:

Code:
C:\Program Files\Calibre2>calibredb list -s 'title:"The Twins"'
id title authors
Removing the escaping gets me back to 'too many hits':

Code:
C:\Program Files\Calibre2>calibredb list -s title:"The Twins"
id   title              authors
772  Time of the Twins  Margaret Weis
3039 The Twins          Gary Alan Wassner
mobichuck is offline   Reply With Quote
Old 03-17-2011, 11:40 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 26,154
Karma: 5381911
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Ah you're on windows, the windows command line is totally crippled, I have no idea how you'd need to get escaping working in windows.
kovidgoyal is offline   Reply With Quote
Old 03-17-2011, 11:50 AM   #5
mobichuck
Junior Member
mobichuck began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 2
Quote:
Originally Posted by kovidgoyal View Post
Ah you're on windows, the windows command line is totally crippled, I have no idea how you'd need to get escaping working in windows.


Figures! Thanks for the help thus far, you - as usual - go above and beyond what anyone supporting software - even commercial software - would ever be expected to do. I'll try some alternate shells and/or the Windows API to get there. Glad to know I do have good syntax; thanks again.
mobichuck is offline   Reply With Quote
Old 03-17-2011, 11:54 AM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 26,154
Karma: 5381911
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The search code used in calibredb and the GUI is identical (they call the same function), so if it works in one, it has to work in the other (provided you can get the escaping working).

Another alternative (at least on unix) is to pass the output through grep and use that to filter.
kovidgoyal is offline   Reply With Quote
Old 03-17-2011, 01:13 PM   #7
chaley
"chaley", not "charley"
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: 5,686
Karma: 1137958
Join Date: Jan 2010
Location: France
Device: Many android devices
Dos cmd is indeed broken, getting very confused by escaped quotes ("") and spaces, but the following works on Win7.
Code:
calibredb list -s "title:"""=The Twins""
chaley is offline   Reply With Quote
Old 03-17-2011, 02:27 PM   #8
mobichuck
Junior Member
mobichuck began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 2
Success!

Quote:
Originally Posted by chaley View Post
Dos cmd is indeed broken, getting very confused by escaped quotes ("") and spaces, but the following works on Win7.
Code:
calibredb list -s "title:"""=The Twins""
Holy cow, that did it! Thanks *so* much. PowerShell didn't want to seem to cooperate either, even using "here-strings" and/or the backtick (yes, they use the backtick!) escape character.

Just for posterity's sake, that command also works on XP.
mobichuck is offline   Reply With Quote
Old 03-21-2011, 01:40 AM   #9
reading
Junior Member
reading began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Mar 2011
Device: Kindle
or this closes the quotes properly and shows how you can add multiple filters

calibredb.exe list -s "title:"""The Twins""" author:"""Gary Alan Wassne""" "
reading is offline   Reply With Quote
Old 03-21-2011, 01:28 PM   #10
collin8579
Member
collin8579 began at the beginning.
 
Posts: 21
Karma: 10
Join Date: Mar 2011
Device: Kindle
This is slightly different question but possibly connected, is there a way to search/sort by entries within the metadata that are identical in 2 different fields?
For instance I messed up and copied my author to series field for 1500 books,, and can't seem to find an easy way to sort/search to allow me to remove that error

Is there anyway to **imaginary syntax** Authorseries field variable?)

thanks<
collin8579 is offline   Reply With Quote
Old 03-21-2011, 04:54 PM   #11
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by collin8579 View Post
Is there anyway to **imaginary syntax** Authorseries field variable?)
Yes, sort of, and I answered you in the other thread. http://www.mobileread.com/forums/sho...02&postcount=8
Starson17 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
epub in formats list - add open with, or edit, option cybmole Calibre 4 01-14-2011 06:28 AM
calibredb list --output-format=xml no longer supported Mekk Library Management 6 06-11-2010 08:13 AM
Science Fiction Bellamy, Edward: Equality, v.1, 13 May 2008. Patricia BBeB/LRF Books 1 05-18-2008 03:27 AM
Science Fiction Bellamy, Edward: Equality, v.1, 13 May 2008. Patricia IMP Books 0 05-12-2008 08:56 PM


All times are GMT -4. The time now is 12:50 PM.


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