View Single Post
Old 09-11-2019, 12:53 PM   #14
ldmobi began at the beginning.
Posts: 14
Karma: 10
Join Date: Jan 2018
Device: Kindle Oasis 2
I would need the exact opposite: I would like to set my tags in Calibre and mirror them in Mac OS, do you have any advice?

Originally Posted by EmilThelonius View Post
So now a first solution (for now):
A short Tip for those of you who want to translate the Tags of the Finder (f.e. made by Hazel to the Calibre library.

Calibre stores its tags (and other metadata) in the metadata.db database file <del>next to the PDF, Epub or Mobi in the same directory</del> in the calibre library. To access the metadata of calibre you need the calibredb command line, the ID of the book, the Tag you want to add and a nice Program which is called Hazel to automate the process (maybe you can do that with a folder-script, but I am not sure).
The ID is within the folder name containing the book file. So the folder is the one which we want to process with Hazel. In Hazel my setup is:

What it does: it tells Hazel to process all folders which have a certain "Full Name" (because we want to include the folders with a "." in the name) that contains a file that has the tag "Hegel". So we want to add the tag with the Book-ID <del>to all of the metadata.opfs within such a folder we want to add the tag "Hegel"</del> to the metadata.db database in the library so that calibre recognizes those tags.
As the ID needed by calibredb to add such a tag is within the name of the folder (in brackets), we can now extract the ID from the $1 (which Hazel gives the shell script: The File Hazel processes) and use it in the shell script:


#tells $i to be the number in in brackets of the folder name
i=$(echo "$1" | awk -F'[()]' '{print $2}')

#tells $a to be the tag Hegel
a='-f "tags:Hegel"'

eval calibredb set_metadata "$a" "$i"
Make sure that Calibre is closed otherwise the script will deliver an error.
Now: wherever I wrote "Hegel" you can add every tag you want (or multiple) to insert into calibre. You will need a rule in Hazel for every Tag you want to add *so simply copy your Hazel rule and change the Tags.

If you know of a better way or see any flaws or possible improvements of that Hazel rule, please write me!
ldmobi is offline   Reply With Quote