Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
kindle "My Clippings.txt" splitter
if (empty($argv[2])) {
throw new Exception('usage: <this file> "/path/to/My Clippings.txt" /path/to/ouputfiles');
$myClippingsFile = $argv[1];
$splitDir = $argv[2];
$bookAndNotes = array();
// read lines
$notes = explode("==========", file_get_contents($myClippingsFile));
if (empty($notes)) {
throw new Exception("empty or wrong file specified");
foreach ($notes as $note) {
// split title and text
$lines = array_slice(explode("\n", $note), 1);
$title = array_shift($lines);
$title = preg_replace('/([^a-z0-9- ])/i', '', $title);
$text = implode("\n", $lines);
// append to file name if the same note does not exist already
$fileName = __DIR__ . "/notes/notes_$title";
if ($text && strpos(@file_get_contents($fileName), $text) === false) {
file_put_contents($fileName, $text, FILE_APPEND);

This comment has been minimized.

Copy link
Owner Author

elvisciotti commented Jul 9, 2012

install from the shell (Mac and Linux)

sudo wget -O /usr/local/bin/kindle-splitter && chmod +x /usr/local/bine/kindle-splitter


mkdir ~/splittedKindleClippings/
kindle-splitter /media/Kindle/documents/My\ Clippings.txt ~/splittedKindleClippings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.