Skip to content

Instantly share code, notes, and snippets.

@cgarrard
Created May 18, 2013 01:22
Show Gist options
  • Save cgarrard/5602866 to your computer and use it in GitHub Desktop.
Save cgarrard/5602866 to your computer and use it in GitHub Desktop.
Shared notebooks in Evernote do not allow anyone but the notebook owner to tag notes. I wanted people to be able to add a note and tag it, so I came up with this and set it to run periodically on one of my computers. Add "tag:xxx" (without the quotes, and where xxx the tag you want to add) to the title of the note, and this script will find all …
import evernote.edam.userstore.constants as UserStoreConstants
from evernote.api.client import EvernoteClient
from evernote.api.client import NoteStore
auth_token = "put-your-auth-token-here"
client = EvernoteClient(token=auth_token, sandbox=False)
note_store = client.get_note_store()
# Get the tags and their guids for tagging later
tags = note_store.listTags()
tag_guids = {}
for tag in tags:
tag_guids[tag.name.lower()] = tag.guid
# Find notes that need to be tagged
filter = NoteStore.NoteFilter()
filter.words = "intitle:tag:"
spec = NoteStore.NotesMetadataResultSpec()
spec.includeTitle = True
spec.includeTagGuids = True
notes = note_store.findNotesMetadata(auth_token, filter, 0, 10, spec)
# For each note, parse out the tag and the update the note
for note in notes.notes:
if note.tagGuids == None:
note.tagGuids = []
tags = note.title.split("tag:")
for tag in tags[1:]:
note.tagGuids.append(tag_guids[tag.strip().lower()])
note.title = tags[0].strip()
note_store.updateNote(auth_token, note)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment