Skip to content

Instantly share code, notes, and snippets.

@allanlw
Created July 11, 2017 01:46
Show Gist options
  • Save allanlw/fb80d85c15036a089bc31a6c41227ee9 to your computer and use it in GitHub Desktop.
Save allanlw/fb80d85c15036a089bc31a6c41227ee9 to your computer and use it in GitHub Desktop.
anki-dupes
# Quick script for finding cards that are dupes based on the sort field
from collections import defaultdict
q = defaultdict(list)
for (k,v) in [ (anki.utils.stripHTML(y.fields[y.col.models.sortIdx(y._model)]), y) for y in [mw.col.getNote(x) for x in mw.col.findNotes("deck:Japanese")]]:
q[k].append(v)
dupes = [(k,v) for (k,v) in q.items() if len(v) > 1]
for k,vs in dupes:
for b in vs:
b.addTag("allandup")
b.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment