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 12-10-2009, 07:38 PM   #1
macr0t0r
Connoisseur
macr0t0r doesn't littermacr0t0r doesn't litter
 
macr0t0r's Avatar
 
Posts: 91
Karma: 108
Join Date: Jan 2008
Device: Palm Treo 680, Sony Reader
Question Defining Metadata with "calibredb add" command line function.

Okay, I'm back with more command-line stuff. It's high time I dump my entire library in Calibre.

However, some files have done a poor job of labeling metadata. Sometimes it's by directory name, and sometimes it's in the file itself (yah, it's a mess...that's why I'm putting it in Calibre). My problem is that the "calibredb add" function doesn't appear to support defining metadata (--author "John Smith" --Title "Horribly Formatted Book"). There is the "set_metadata" function, but that requires the Database ID, and the calibredb add function does not return that value. I can't be sure how successful the import was, so I can't really automate what title to search for with the "list" command in order to get the database ID.

I want to add a book, get the database id, and then use the id to set metadata and cover page. What is the best way to get the database id of the last added book?

- Jim
macr0t0r is offline   Reply With Quote
Old 12-10-2009, 08:00 PM   #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: 25,908
Karma: 5035037
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Here's a BASH command line to do that

calibredb list | tail -n2 | head -n1 | cut -f1 -d " "

calibredb list by default sorts on timestam which means the last entry will have the id of the last added book
kovidgoyal is offline   Reply With Quote
 
Enthusiast
Old 12-11-2009, 12:02 AM   #3
macr0t0r
Connoisseur
macr0t0r doesn't littermacr0t0r doesn't litter
 
macr0t0r's Avatar
 
Posts: 91
Karma: 108
Join Date: Jan 2008
Device: Palm Treo 680, Sony Reader
That'll work. Thanks!
- Jim
macr0t0r is offline   Reply With Quote
Old 03-01-2012, 07:36 PM   #4
Zatakawa
Enthusiast
Zatakawa ought to be getting tired of karma fortunes by now.Zatakawa ought to be getting tired of karma fortunes by now.Zatakawa ought to be getting tired of karma fortunes by now.Zatakawa ought to be getting tired of karma fortunes by now.Zatakawa ought to be getting tired of karma fortunes by now.Zatakawa ought to be getting tired of karma fortunes by now.Zatakawa ought to be getting tired of karma fortunes by now.Zatakawa ought to be getting tired of karma fortunes by now.Zatakawa ought to be getting tired of karma fortunes by now.Zatakawa ought to be getting tired of karma fortunes by now.Zatakawa ought to be getting tired of karma fortunes by now.
 
Zatakawa's Avatar
 
Posts: 37
Karma: 500222
Join Date: Mar 2011
Device: none
Sorry for reviving this old thread, but your BASH command does not always work, Kovid. If a title or author is very long and needs to lines to be displayed, tail -n2 does not work anymore.

Fiddling around with "--line-width=LINE_WIDTH" also does not offer a solution because line width is never longer than the book with the longest title.

EDIT: One workaround is to use -f timestamp

Last edited by Zatakawa; 03-01-2012 at 10:30 PM.
Zatakawa 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
Feature Request - cover browse in the "Fetch Metadata from server" function nathander13 Calibre 1 01-30-2010 02:11 PM
Problem updating metadata (using mobi2mobi command line and gui) whitearrow Kindle Formats 3 12-05-2009 07:07 PM
[Enhancement suggestion] Folders when save books in "Add Books" function simonbcn Calibre 1 08-30-2009 12:59 PM
Command line calibredb set_metadata problem Nedan Calibre 1 02-27-2009 08:44 PM
iLiad "joe" command line text editor bobj iRex Developer's Corner 3 06-02-2008 03:03 PM


All times are GMT -4. The time now is 04:03 PM.


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