Couldn't find a way to do this with the GUI, so here's a script using Calibre's "ebook-meta" command that, for each .mobi file in a directory tree, changes the author metadata in the file to be:
..directory the file is in..original author..
Where the name of the directory the file is in is something you are using as a category, e.g. "stuff for my x class" or "learning about kiwi fruit".
I choose .. as it's fast to type on the Kindle PaperWhite 2 virtual keyboard when you do searches.
You can run in as many times as you want, nothing will change unless you move files around, at which point the author metadata will change to reflect that.
I did look into - and get
helpful pointers regarding - doing this from the GUI, but in the end this seems faster and a whole lot simpler for my current needs.
Of course would be happy to know if others have already done this in a more robust fashion.
Code:
#!/bin/bash
EBOOKMETA="/Applications/calibre.app/Contents/MacOS/ebook-meta"
KINDLEROOT="/Volumes/Kindle"
# --
if [ ! -x $EBOOKMETA ]; then
echo "ERROR: $EBOOKMETA doesn't exist"
exit 200
fi
if [ ! -d $KINDLEROOT ]; then
echo "ERROR: $KINDLEROOT doesn't exist"
exit 200
fi
# --
find $KINDLEROOT -type f -name '[a-zA-Z0-9]*.mobi' -print0 | while read -d $'\0' FILE
do
AUTHOR="$(/Applications/calibre.app/Contents/MacOS/ebook-meta "$FILE" --to-opf=/dev/null | grep ^Author | sed 's/Author(s) : //g')"
FOLDER="$(basename $(dirname "$FILE"))"
if [[ $AUTHOR == *".."* ]]; then
METAAUTHOR="$(echo $AUTHOR | awk -F '\\..' '{print $3}')"
$EBOOKMETA "$FILE" -a "..${FOLDER}..${METAAUTHOR}.."
else
$EBOOKMETA "$FILE" -a "..${FOLDER}..${AUTHOR}.."
fi
done
This is alpha - use at your own risk!