Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 01-19-2015, 03:00 PM   #1
danjcla
Junior Member
danjcla began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jan 2015
Device: Kindle Paperwhite
Unhappy fw5.6.1+ — Is abuse of the author field only option for library management?

Is abusing either the title or author field - along the lines of the below proof-of-concept script - pretty much the only way to do off-device / non-manual organization of books on a Kindle Paperwhite 2 with firmware 5.6.1 (that hadn't previously been rooted)?

I've read a lot of stuff on these forums and that would seem to be the case, but I haven't found a post that says it point blank, so thought I'd ask, and also share the atrocious ugliness below :-)

Code:
#!/bin/bash



# This script changes the author metadata to be in this form with <> as 
# the delimiter:
# <>directory the book is in<>original author name<>

# -->> Need to be made idempotent before it'll be really usable day-to-day

# It'd also be useful to add "X of Y" to files in a directory, so it'd be easy
# to manually make sure everything in a directory is also in a collection.



EBOOKMETA="/Applications/calibre.app/Contents/MacOS/ebook-meta"
# http://manual.calibre-ebook.com/cli/ebook-meta.html

find /Volumes/Kindle -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"))"
  $EBOOKMETA "$FILE" -a "<>$FOLDER<>$AUTHOR<>"
done

Last edited by danjcla; 01-19-2015 at 03:08 PM.
danjcla is offline   Reply With Quote
Old 01-19-2015, 03:53 PM   #2
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 10,501
Karma: 18151936
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW & PW2; Kobo H2O & Forma
Note that, if you're already using Calibre, a Calibre plugboard is usually the best way to achieve that kind of shenanigans . The fact that such a feature exists pretty much answers your question: yep, it's a widely used workaround, and has been for quite a while .
NiLuJe is offline   Reply With Quote
Advert
Old 01-19-2015, 04:06 PM   #3
danjcla
Junior Member
danjcla began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jan 2015
Device: Kindle Paperwhite
Thanks! I'm new to all this and had no idea that feature existed. I'll def be exploring it :-)
danjcla is offline   Reply With Quote
Old 01-19-2015, 06:18 PM   #4
danjcla
Junior Member
danjcla began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jan 2015
Device: Kindle Paperwhite
The more I look into it the less it seems like templates / the GUI (sans writing or finding some custom module) in general could do what I'm interested in doing.

That is support a fast workflow where I occasionally download a bunch of .mobi files via a web browser directly to my kindle, putting them in / creating the right categorization folder at that time, and then run some program that abuses the Author metadata to allow it to be used for categorization based on the folder containing the file.

It looks like the GUI workflow would be more like this:
1. Download .mobi files to temporary directory structure on machine running Calibre
2. Open Calibre
3-4. Import files into Calibre in batches from each temporary directory
3-4. For each batch, add tag equivalent to temporary folder name
5. Do "send to device" (I keep looking for a sync all button...)
6. Remove files, but not directories, from local temporary directory structure

Or alternatively, maybe download to kindle, then copy over to local using the GUI, then copy back (filtered through plugboard and with template that will put files in same folder hierarchy).

The two GUI options just seem... inefficient and annoying.

Also I have a laptop, work desktop, home desktop, etc., not sure how I'd keep Calibre in sync across all those machines.

But maybe this isn't the right forum for this question? If so please tell me and I'll re-ask elsewhere.

Last edited by danjcla; 01-19-2015 at 06:57 PM.
danjcla is offline   Reply With Quote
Old 01-19-2015, 06:51 PM   #5
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 10,501
Karma: 18151936
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW & PW2; Kobo H2O & Forma
That completely depends on how willing you are to commit to actually using Calibre to manage your library. If you don't, it might indeed not be the most efficient workflow .

(I personally keep my desktop's & laptop's Calibre library via rsync).
NiLuJe is offline   Reply With Quote
Advert
Old 01-19-2015, 07:03 PM   #6
danjcla
Junior Member
danjcla began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jan 2015
Device: Kindle Paperwhite
Thumbs up

Cool, at least good to know I'm not missing something. My major pain point is the initial collection of metadata... right when I download something I know how to categorize it, but 10 minutes later when I'm done downloading stuff to look over and maybe read, if it's all in one folder, it's hopeless.

Hmmm although thinking about it more I could just rename the file instead of put it in a subdirectory, and then the import could use that info, since "Add books -> Control the adding of books" looks like it can do anything based on file names ...

d'oh

Thanks again,
-Danny
danjcla is offline   Reply With Quote
Old 01-19-2015, 08:47 PM   #7
danjcla
Junior Member
danjcla began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jan 2015
Device: Kindle Paperwhite
The path of least resistance seemed to be to just spend a few more minutes to fix up the script a bit; this version you can run multiple times without messing anything up, and it'll also correctly change the author metadata based on moving a file to a new directory.

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 201
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
danjcla is offline   Reply With Quote
Old 01-19-2015, 09:27 PM   #8
danjcla
Junior Member
danjcla began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jan 2015
Device: Kindle Paperwhite
Thread moved to:

MobileRead Forums > E-Book Software > Calibre > Library Management > 'Directory tree in-place "author" -> "folder + author" script (where folder=category)'
danjcla is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Author field moomintroll Calibre 1 03-29-2014 05:03 PM
[Solution] Kindle Paperwhite: Lastname_Firstname author, Series in author field Katsunami Library Management 6 11-15-2013 11:45 AM
Kindle Paperwhite: Lastname_Firstname author, Series in author field Katsunami Library Management 0 09-10-2013 12:43 PM
fw5.3.3 for KPW and fw5.3.2 for KT: how different? pirl8 Kindle Developer's Corner 7 03-03-2013 09:26 AM
Author field update and author sort derangedhermit Calibre 4 01-23-2013 04:10 AM


All times are GMT -4. The time now is 01:57 AM.


MobileRead.com is a privately owned, operated and funded community.