2

Using calibre from the command line, in debian testing, how can I insert a tag with the syntax being

    ebook-meta ebook_file --tags rhubarb

but for a range of files, but all by the same author so just need the tag of his/her name?

This is used for indexing and sorting out books on a Kindle.

2

The easiest way, assuming all the relevant files are in the same directory, is:

for f in *; do ebook-meta "$f" --tags rhubarb

If the files can be in various sub directories, use find (this assumes that the only files in all sub directories are ebooks. Since this is likely not true, you should use something additional like -name "*.ebook" or whatever extension your ebooks have):

find . -type f -exec ebook-meta '{}' --tags rhubarb \;
  • @ChrisDown argh, thanks, forgot the quotes which were the whole point of the answer. – terdon Sep 1 '13 at 14:32
  • @~/kindle-backup/34-wilbur-smith-Kindle-Collection]$ [9570]>; for f in *; do ebook-meta "$f" --tags wilbur-smith > ^C @~/kindle-backup/34-wilbur-smith-Kindle-Collection]$ [9570]>; for f in *; do ebook-meta "$f" --tags wilbur-smith > ^C Doesn't work, but I cant see why. Any ideas please? – boudiccas Sep 1 '13 at 15:11
  • find . -type f exec ebook-meta '{}' --tags wilbur-smith \; find: paths must precede expression: exec Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression] – boudiccas Sep 1 '13 at 15:12
  • There was a '-' missing before 'exec'. – Dubu Sep 1 '13 at 17:14
  • @user205787 as Dubu pointed out, I had forgotten the - before -exec, try again with the modified answer. – terdon Sep 1 '13 at 17:20
0

You must have the ebooks of an author in a directory. cd to this directory an run:

for var in $(ls); do ebook-meta $var --tags rhubarb; done

if the filename has spaces, you must modify the IFS (Internal Field Separator):

oldIFS=$IFS
IFS='\n'
for var in $(ls); do ebook-meta $var --tags rhubarb; done
IFS=$oldIFS

Or the same in a single command:

oldIFS=$IFS && IFS='\n' && for var in $(ls); do ebook-meta $var --tags rhubarb; done && IFS=$oldIFS

  • Thanks for this but its not working, this is part of the puitput - – boudiccas Sep 1 '13 at 6:27
  • Thanks for this but its not working, this is part of the output - the output is too long for here but its at paste.debian.net/33088 . I think that theres some problem with the 'cli.py' module itself – boudiccas Sep 1 '13 at 6:36
  • 4
    NEVER parse ls, and twice never when working with file names that are likely to have spaces. – terdon Sep 1 '13 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.