# Deck duplication \[Support thread\]

**URL:** <https://forums.ankiweb.net/t/deck-duplication-support-thread/20691>\
**Category:** Add-ons\
**Created:** [June 11, 2022, 2:24pm UTC](https://forums.ankiweb.net/t/deck-duplication-support-thread/20691 "2022-06-11T14:24:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TRIAEIOU](https://avatars.discourse-cdn.com/v4/letter/t/df788c/32.png) [@TRIAEIOU](https://forums.ankiweb.net/u/TRIAEIOU)\
**Post date:** [June 11, 2022, 2:24pm UTC](https://forums.ankiweb.net/t/deck-duplication-support-thread/20691/1 "2022-06-11T14:24:17Z")

</div>

Addon to clone decks (and delete clone notes) - [Deck duplication - AnkiWeb](https://ankiweb.net/shared/info/1779572689)

---

<div class="post-metadata">

**Author:** ![LurkedLurkingLurker](https://avatars.discourse-cdn.com/v4/letter/l/d2c977/32.png) [@LurkedLurkingLurker](https://forums.ankiweb.net/u/LurkedLurkingLurker)\
**Post date:** [April 10, 2023, 7:08pm UTC](https://forums.ankiweb.net/t/deck-duplication-support-thread/20691/2 "2023-04-10T19:08:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TRIAEIOU](https://avatars.discourse-cdn.com/v4/letter/t/df788c/32.png) [@TRIAEIOU](https://forums.ankiweb.net/u/TRIAEIOU)\
**Post date:** [April 10, 2023, 9:25pm UTC](https://forums.ankiweb.net/t/deck-duplication-support-thread/20691/3 "2023-04-10T21:25:54Z")

</div>

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:

```auto
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.
