Skip to content

Instantly share code, notes, and snippets.

@leonheess
Forked from sliceofbytes/txt-to-google-keep-notes.py
Last active November 20, 2018 21:08
Show Gist options
  • Save leonheess/0a7ce31aa5215ae0ef018362be4b81a3 to your computer and use it in GitHub Desktop.
Save leonheess/0a7ce31aa5215ae0ef018362be4b81a3 to your computer and use it in GitHub Desktop.
Add Text Files as Google Keep Notes
# import a directory of text files as google keep notes
# text filename is used for the title of the note
import gkeepapi, os
# your google account email
username = 'username@domain.tld'
# if you have 2FA enabled use https://accounts.google.com/b/0/DisplayUnlockCaptcha
# press continue and create an app-specific password to use here:
password = 'your app password'
keep = gkeepapi.Keep()
keep.login(username, password)
dir_path = os.path.dirname(os.path.realpath(__file__))
for fn in os.listdir(dir_path):
if os.path.isfile(fn) and fn.endswith('.txt'):
with open(fn, encoding="utf8") as mf:
data = mf.read()
keep.createNote(fn.replace('.txt', ''), data)
keep.sync()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment