|12-10-2009, 08:38 PM||#1|
Join Date: Jan 2008
Device: Palm Treo 680, Sony Reader
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?
|12-10-2009, 09:00 PM||#2|
creator of calibre
Join Date: Oct 2006
Location: Mumbai, India
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
|03-01-2012, 08:36 PM||#4|
Join Date: Mar 2011
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 11:30 PM.
|Thread Tools||Search this Thread|
|Thread||Thread Starter||Forum||Replies||Last Post|
|Feature Request - cover browse in the "Fetch Metadata from server" function||nathander13||Calibre||1||01-30-2010 03:11 PM|
|Problem updating metadata (using mobi2mobi command line and gui)||whitearrow||Kindle Formats||3||12-05-2009 08:07 PM|
|[Enhancement suggestion] Folders when save books in "Add Books" function||simonbcn||Calibre||1||08-30-2009 01:59 PM|
|Command line calibredb set_metadata problem||Nedan||Calibre||1||02-27-2009 09:44 PM|
|iLiad "joe" command line text editor||bobj||iRex Developer's Corner||3||06-02-2008 04:03 PM|