1

The problem

I want to create a directory with my notes from Evernote in files with the Markdown format. I found out that this can be made using Geeknote, but for each notebook every time.

How to create a bash script that synchronizes a directory, where each subdirectory is a different notebook, and inside these the markdown files?

While you make suggestions, I will keep this question updated.

Some background commands to start from

The command to two-way sync using Geeknote is the following:

gnsync --path ~/Evernote/Ler --logpath ~/.log/geeknote.log --format markdown --notebook ".Ler" --two-way TWO_WAY

The command to list my notebooks is:

geeknote notebook-list

Partial solution

@RichardAnderson suggested the following code to list and loop into the Evernote notebooks, I tested in my system and it is working. The problem is that the geeknote notebook-list command waits for user action during the listing, I also couldn't find a way to circumvent that.

Just create a file with the following content:

    #!/bin/bash
    geeknote notebook-list > /tmp/list.txt
    Note_List=$(cat /tmp/list.txt | grep -v Total | cut -d : -f 2)
    for i in $Note_List; do
        gnsync --path ~/evernote --logpath ~/.log/geeknote.log --format markdownn --notebook "$i" --two-way TWO_WAY
    done

Don't forget to change to your path.

ATTENTION! If you have images or heavily formatted notes in your evernote account, please note that this method can potentially remove formatting and data within notes. So use at your own risk!

How to solve the last bit?

If you know a way of circumventing the need for user action during the geeknote note-list command, please drop a line below.

0

I went for the bash solution:

function sync_notebook {
  gnsync --path ~/Evernote/$1 --logpath ~/.log/geeknote$1.log --format markdown --notebook "$1" --two-way TWO_WAY
}


function sync_all {
  for D in *; do sync_notebook $D; done
}

I added these to my .bashrc.

The first is just a wrapper to gnsync. It takes a single argument, the name of a notebook. The second is a bash loop over all of the folders in a directory. The names of the folders match the names of notebooks in evernote.

Still haven't figured how not to kill pdfs in sync.

|improve this answer|||||
1

I was looking for the same thing. This is what I came up with.

#!/bin/bash
geeknote notebook-list > /tmp/list.txt
Note_List=$(cat /tmp/list.txt | grep -v Total | cut -d : -f 2)
for i in $Note_List; do
    gnsync --path ~/evernote --logpath ~/.log/geeknote.log --format markdown --notebook "$i" --two-way TWO_WAY
done

You will probably have to press enter a few times after starting. I am not sure how to treat the geeknote notebook-list command to eliminate the need for having to press enter.

|improve this answer|||||
  • You could try the yes command - see man yes – Hamish Downer Jul 26 '15 at 13:50
1

I don't know, how to circumvent the need to interact, but I know how to automate it: expect. You can install it with apt-get. Here's my expect script, which did the trick for me:

#!/usr/bin/expect -f

spawn geeknote "notebook-list"

expect "More"
sleep 2
send "j"
interact

Then you can use this in place of geeknote notebook-list:

./geeknote-expect-script > /tmp/list.txt
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.