Reputation: 433
I use a GTD-based system in Evernote, in which each project has a tag. Some of my projects are inactive, and have no 'next action' - i.e the tag has no notes attached. I accidentally clicked Delete unused Account tags
last night, and none of my backups have the lost data; I am a very sad bunny.
How can I backup these unused tags in future? I'd prefer an ENEX, but am happy with e.g. a plain-text list of names.
I was using Evernote's 'export' menu-option, but it - it turns out - only exports notes and their tags, not unused tags. I've tried ENScript.exe (ENScript exportNotes /q any:
) and that does the same: notes & their tags, but no other tags. The only thing left for me to try is installing an SDK and 'rolling my own' call to NoteStore.listTags - which I can't be certain will work, given the previous two results.
Is there a way to export unused tags from Evernote? Can the API do it?
Upvotes: 0
Views: 238
Reputation: 3469
Yes, you can, through the API. Use the listTags
method to get all the tags in your Evernote account, this will list tags that are "attached" to a note and tags that are not "attached" to a note. You can then compare this to notes that are "attached" to notes by calling listTagsByNotebook
on every notebook (you can get a list of all the notebooks by calling the listNotebooks
method). Evernote's Cloud API is different that their local scripting APIs (i.e AppleScript and VBScript)
listTags
documentation
listNotebooks
documentation
listTagsByNotebook
documentation
Example below is in Python:
from evernote.api.client import EvernoteClient
#setup Evernote Client
client=EvernoteClient(token="S=s432:U=489be66:E=1545a0ad962:C=14d0259ad08:P=1cd:A=en-devtoken:V=2:H=e3e3c9ea30c6879c54918794fad333ae", sandbox=False)
#get note store object to call listTags, listTagsByNotebook, and listNotebooks on
noteStore=client.get_note_store()
tags=noteStore.listTags() #get list of all tags
allTags = [tag.name for tag in tags] #put all the names of the tags in a list
#get a list of all notebooks
notebooks = noteStore.listNotebooks()
#get all tags for each notebook and store them in a list
attachedTags = []
for notebook in notebooks:
notebookTagList = noteStore.listTagsByNotebook(notebook.guid)
notebookTagNames = [tag.name for tag in notebookTagList]
attachedTags+=notebookTagNames
#compare lists and print "unattached" tags
print("\nThe following is a list of \"unattached\" tag names in your Evernote account:")
for tag in allTags:
if tag not in attachedTags:
print(" *%s"%tag)
print("")
You can get a developer token for your production account (Evernote has a sandbox for developers too) here: https://www.evernote.com/api/DeveloperToken.action
Evernote SDKs are on Github: https://github.com/evernote
Documentation is at: https://dev.evernote.com
API reference: https://dev.evernote.com/doc/reference
Upvotes: 1