Quote:
Originally Posted by kovidgoyal
You're doing it wrong
You want to start with calibredb list to get a list of all books and their ids,
calibredb list -f formats
Then iterate over the books, converting them, sending the converted output to a temp file ad add the temp file like this
calibredb add_format book_id tmpfile
|
...
something like this...
Code:
#!/bin/bash
# Search for which books we want. Find books that aren't in EPUB yet.
calibre-search='not formats:"=EPUB"'
regex="(\d+) \[([^\]]*)\]"
# Search calibredb, iterate over each result.
calibredb list -s "$calibre-search" -f formats | while read line; do
# Extract info from lines into bash_rematch
[[ "$line" =~ "$regex" ]]
ebook-convert "${BASH_REMATCH[2]}" "/tmp/converted.epub"
calibredb add_format "${BASH_REMATCH[1]}" "/tmp/converted.epub"
done