|
|
Thread Tools | Search this Thread |
01-19-2015, 09:20 PM | #1 |
Junior Member
Posts: 7
Karma: 10
Join Date: Jan 2015
Device: Kindle Paperwhite
|
Directory tree in-place "author" -> "folder + author" script (where folder=category)
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 Last edited by danjcla; 01-19-2015 at 09:28 PM. |
02-01-2015, 10:28 PM | #2 |
Fanatic
Posts: 515
Karma: 1470724
Join Date: Jul 2013
Location: Quebec CA
Device: android 4 (samsung tablet and asus tablet)
|
Ummm, I'm trying to figure out what the purpose of this script is. How is it used and why?
|
Advert | |
|
02-01-2015, 11:23 PM | #3 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
It is used to change the author field of ebooks depending on the folder structure. The purpose: to avoid having to use calibre's library management capabilities just to get plugboards.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Swaping "titles" versus "author" | duytrung | Library Management | 11 | 12-08-2014 10:53 PM |
Apple Mac now have a file extension ".iba" for the program "iBooks Author." | brucehobson | Calibre | 3 | 09-15-2014 07:46 PM |
"open containing folder" gives no such directory under Linux | exachillus | Calibre | 1 | 01-30-2014 01:02 AM |
"Send to Main Memory" greyed out after "Connect to folder" | myce | Calibre | 16 | 01-15-2014 04:03 PM |
A warning for Linux users: slow "Add Books", "Unknown" title and Author | rolgiati | Library Management | 8 | 07-24-2013 04:36 PM |