Friday, May 17, 2024
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 934  / 3 Years ago, thu, november 25, 2021, 10:58:12

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.


More From » command-line

 Answers
1

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.


[#21815] Thursday, November 25, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
azaaburge

Total Points: 266
Total Questions: 85
Total Answers: 109

Location: Djibouti
Member since Sat, Oct 29, 2022
2 Years ago
azaaburge questions
Thu, Jun 2, 22, 23:28, 2 Years ago
Sun, Oct 17, 21, 05:20, 3 Years ago
Fri, Jun 25, 21, 16:22, 3 Years ago
;