03-17-2011, 10:51 AM | #1 |
Junior Member
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" But when I try and do this via the command-line, like so: Code:
calibredb list -s title:"=The Twins" Code:
calibredb list -s title:"The Twins" 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. |
03-17-2011, 11:21 AM | #2 |
creator of calibre
Posts: 44,165
Karma: 22670164
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You need to use proper command line escaping
Code:
calibredb list -s 'title:"=The Twins"' |
Advert | |
|
03-17-2011, 11:31 AM | #3 | |
Junior Member
Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 2
|
Quote:
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 Code:
C:\Program Files\Calibre2>calibredb list -s 'title:"The Twins"' id title authors 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 |
|
03-17-2011, 11:40 AM | #4 |
creator of calibre
Posts: 44,165
Karma: 22670164
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.
|
03-17-2011, 11:50 AM | #5 | |
Junior Member
Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 2
|
Quote:
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. |
|
Advert | |
|
03-17-2011, 11:54 AM | #6 |
creator of calibre
Posts: 44,165
Karma: 22670164
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. |
03-17-2011, 01:13 PM | #7 |
Grand Sorcerer
Posts: 11,863
Karma: 7036239
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
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"" |
03-17-2011, 02:27 PM | #8 | |
Junior Member
Posts: 9
Karma: 10
Join Date: Nov 2010
Device: Kindle 2
|
Success!
Quote:
Just for posterity's sake, that command also works on XP. |
|
03-21-2011, 01:40 AM | #9 |
Junior Member
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""" " |
03-21-2011, 01:28 PM | #10 |
Member
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< |
03-21-2011, 04:54 PM | #11 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
|
|
|
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 |