Skip to content

Instantly share code, notes, and snippets.

@zhulianhua
Last active June 1, 2019 11:05
Show Gist options
  • Save zhulianhua/750b7d11e3cacc10d5bf875be1f506ec to your computer and use it in GitHub Desktop.
Save zhulianhua/750b7d11e3cacc10d5bf875be1f506ec to your computer and use it in GitHub Desktop.
from pyzotero import zotero
zot = zotero.Zotero('000000000', 'user', 'AAAAAAAAAAAAA')
print(zot.count_items())
tags_to_keep = ['writting','english']
tags = zot.everything(zot.tags())
tags_to_remove = list(set(tags).difference(tags_to_keep))
while len(tags_to_remove)>0:
tags = zot.everything(zot.tags())
tags_to_remove = list(set(tags).difference(tags_to_keep))
tags_to_remove_n = tags_to_remove[:min(len(tags_to_remove),50)]
zot.delete_tags(*tags_to_remove_n)
print('Number of Remaining Tags:',len(tags_to_remove))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment