Addon to clone decks (and delete clone notes) - Deck duplication - AnkiWeb
Hello, I really like your deck duplication addon, but (I know that add on description says it doesn’t do this) is there a way for tags to also get duplicated alongside the cards? If the addon definitely cannot do this, do you have any ideas on how this could be done (Deck duplication with tags, basically). Thank you again for the addon.
Currently the addon doesn’t do it (mainly because I don’t use tags much) but it should not be that hard to also copying the tags (without out looking at the db I am guessing the tags are one table and there is a relation table so one only needs to copy the relevant records in the relation table). However there are some other things higher up in the priority list for me but if anyone knows how to code you’re free to use my code however you see fit (or create a PR), it should be somewhere here:
def _duplicate_notes(sid, did):
nonlocal note_cnt
changes = collection.OpChanges()
query = f'SELECT DISTINCT nid FROM cards WHERE did = {sid}'
for nid, in col.db.all(query):
snote = col.get_note(nid)
dnote = col.new_note(snote.note_type())
for key, val in snote.items():
dnote[key] = val
change = col.add_note(dnote, did)
# Somewhere here
note_cnt +=1
return changes
As a side note, having fidgeted a little with the cards and notes without direct db calls in another unreleased addon (that sorts clozes in ascending order while retaining learning state) I realize the above could be made (and easier to maintain) without any direct db-calls.