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

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 02-23-2014, 05:32 PM   #1
spedinfargo
Zealot
spedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipedia
 
Posts: 116
Karma: 47540
Join Date: Nov 2010
Device: none
Calibredb export: can I do a subset of books (based on a query)?

I see in the calibredb page there is a way to either export all of the books or a single ID:

calibredb export [options] ids

Does anyone have an example of how to export just a subset of books based on a search? For instance, I want to only export the Recipe books (author = 'calibre'). I'm assuming I would have to do a two step process and come up with a list of ids that match my query and then call 'calibredb export' one by one on those ids.

Any thoughts on the easiest way to do this?

Thanks.
spedinfargo is offline   Reply With Quote
Old 02-23-2014, 07:13 PM   #2
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 2,895
Karma: 4212450
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch (Wifi only)
You use
Code:
calibredb list -s "search-term" -f ""
and pipe | the output through a filter to remove the first line, ("id") then pipe the resulting list of ids to
Code:
calibredb export [options]
In bash that would be
Code:
calibredb list -s "search-term" -f "" | tail -n +2 | calibredb export [options]
tail is a linux command to output only the last x lines (or start from line number +2) but I'm not sure how to do the equivalent on Windows, if you are using Windows.
eschwartz is offline   Reply With Quote
 
Enthusiast
Old 02-23-2014, 08:28 PM   #3
spedinfargo
Zealot
spedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipedia
 
Posts: 116
Karma: 47540
Join Date: Nov 2010
Device: none
That sounds about what I thought would be needed. Should be able to pound out a powershell script to do similar...

Thanks for the response...
spedinfargo is offline   Reply With Quote
Old 02-25-2014, 11:12 AM   #4
spedinfargo
Zealot
spedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipedia
 
Posts: 116
Karma: 47540
Join Date: Nov 2010
Device: none
Hi eschwartz,

Quick question: when I do a -f with an empty string (-f "") I get an error on Windows that says a blank string is not acceptable. Do you get the same error on unix?

I can probably work around it and just use "uuid" and parse each line somehow to get the ID... but it would be much nicer if I could just get a list of IDs with the command...
spedinfargo is offline   Reply With Quote
Old 02-25-2014, 02:27 PM   #5
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 2,895
Karma: 4212450
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch (Wifi only)
No I get a list of ids, one per line. calibredb list always gives you the ids field, plus the -f "fields".

Code:
  -f FIELDS, --fields=FIELDS
                        The fields to display when listing books in the
                        database. Should be a comma separated list of fields.
                        Available fields: *annotations,*asin,*file,*filesave,*
                        subseries,*subseries_index,*titlesave,author_sort,auth
                        ors,comments,cover,formats,identifiers,isbn,last_modif
                        ied,pubdate,publisher,rating,series,series_index,size,
                        tags,timestamp,title,uuid
                        Default: title,authors. The special field "all" can be
                        used to select all fields. Only has effect in the text
                        output format.
and ids isn't on the list of available fields.

So passing the empty string I used to clear the default fields, but I have no idea why it's erroring for you.

....

Found it! It's a Windows problem, not calibre. Apparently powershell doesn't like empty strings, see here for how to deal with it: http://stackoverflow.com/questions/1...ing-powershell
eschwartz is offline   Reply With Quote
Old 02-25-2014, 03:01 PM   #6
spedinfargo
Zealot
spedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipediaspedinfargo knows more than wikipedia
 
Posts: 116
Karma: 47540
Join Date: Nov 2010
Device: none
Wow, that's pretty hard-core on the powershell thing. I would have assumed it was a bug with calibredb on windows vs. linux. Nice find.

Putting the double quotes inside of single quotes (or single ticks as someone used to call them) worked fine: '""'

Good find!
spedinfargo is offline   Reply With Quote
Old 02-25-2014, 03:18 PM   #7
eschwartz
Irrational Optimist
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
Posts: 2,895
Karma: 4212450
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch (Wifi only)
I just googled "windows pass the empty string as parameter" but I'll take the compliment anyway.
eschwartz 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
Select books based on info from Conversion > Export Catalog halfcore Library Management 2 10-22-2013 06:15 PM
Need help with adding books via calibredb Benji99 Calibre 1 03-17-2012 12:31 PM
Can Excel SQL query get metadata out of calibredb? unboggling Calibre 24 01-20-2011 02:45 AM
Query about 2 books by Ken Follett lene1949 General Discussions 4 10-15-2010 08:05 AM
how do I export my Kobo books Zepherious Kobo Reader 4 05-29-2010 02:43 PM


All times are GMT -4. The time now is 10:16 AM.


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