It's understandable that Amazon doesn't want to provide a collection mangement application and unfortunately, the collection structure isn't reflected in the Kindle's directory structure, so even though you can mount the Kindle as a file system on your computer, you can't use this to manage collections.
There's been a fair amount of research
on how the Kindle collection system works. Basically, there is a single
JSON file called collections.json
which contains a dictionary
of collections with each entry being a list of SHA-1 hashes of the file names
in each collection. E.g.,
{ "fiction@en-US": {"items": ["*8f0abafc5f8e6686a882c78cac4bcb9f", "*614dd0e977becb4c6f7fa99e64549b12"], "lastAccess": 1291824173119}, "nonfiction@en-US": {"items": ["*7b3b4c3be6d20a51b1b75833a5a8a248"], "lastAccess": 1291824173119} }
It's known how to compute the hash, it's a SHA-1 of the string
/mnt/us/<filename>
(there appear to be some funny
issues about how spaces and dashes are handled). So writing a valid
version of the file is mostly a matter of simple JSON programming.
There's one more problem: the Kindle seems to keep an in-memory cache
of the collections.json
file, so just changing the file
doesn't help. What you need is to force a cache refresh. You would
think a reboot would do it, but actually it seems to force the
cache to be written back to permanent storage, overwriting your
modified version. After all, who would go around writing the permanent
version? The fix here is to do a hard reboot. The procedure I've
found works on the DX is to unplug the Kindle from the computer,
hold the power switch down for about 20 seconds (I hear it's 15 but
maybe I'm counting too fast). This does a hard shutoff, and then
when you press the power switch again it does a complete restart,
reloads the collections.json
, and you're good to go.
Someone has written a Kindle Collections Manager for Kindle, but I don't run Windows and
I wanted to play around a little bit. You can find a primitive
Python script that does this job here. Basically,
you plug in your Kindle, then you can do kcollect add <collection> <file>..
and it will copy the files onto your Kindle (if necessary) and add them to the relevant
collection. Just running with no arguments shows the contents of the collections on
the Kindle.