Delete duplicates in bulk

alonso.juste's Avatar

alonso.juste

03 Dec, 2016 02:24 AM

I know how to find duplicated cards and tag them so I can easily list them in my card browser. After that I can delete them but I have a collection with 20000 cards and 2500 duplicates so it is going to take a while deleting them following this method.
Is there any way to bulk-delete these duplicated cards?

  1. Support Staff 1 Posted by Damien Elmes on 03 Dec, 2016 03:44 AM

    Damien Elmes's Avatar

    Anki has no way of knowing which of the duplicates you wish to keep, so it can't get rid of them automatically. You may find it helpful to sort by creation date, reviews or some other criteria in the browser, which may help you isolate the cards you wish to keep from the others.

  2. 2 Posted by alonso.juste on 03 Dec, 2016 04:03 AM

    alonso.juste's Avatar

    Thanks, Damien.
    I guess I'll have to take it easy then... I have a lot of cards to delete ahead :)

  3. 3 Posted by Soren Bjornstad on 03 Dec, 2016 02:09 PM

    Soren Bjornstad's Avatar

    Hi Miguel,

    If the cards you want to delete follow a pattern (for instance, you have 1,000 cards that are in one deck and 1,000 duplicates in another that you'd like to delete), you may be able to use the tag button and then run a search to find only the set that you wish to delete.

  4. 4 Posted by alonso.juste on 03 Dec, 2016 05:47 PM

    alonso.juste's Avatar

    Hi Soren,
    I'm afraid that is not my case. I have like 2000 cards each one with just one or two duplicates. I would like to delete the latest to review ones, but I haven't found yet a way to do so (and I don't know if it is possible). So I have started everyday to delete around 30-40 repeated cards following the tag/order criteria. It will take a while but it is just a few minutes everyday after my anki session

  5. 5 Posted by alonso.juste on 17 Dec, 2016 04:14 AM

    alonso.juste's Avatar

    Sorry to reopen this topic again but would there be any way to show only the tag 'duplicate' in the front of my card? Using {{Tags}} it shows all the tags from a card.
    Doing that I could see and delete the duplicates while practicing.

  6. Support Staff 6 Posted by Damien Elmes on 18 Dec, 2016 02:09 AM

    Damien Elmes's Avatar

    Anki does not have a built in feature to do that, sorry. You may be able to accomplish it with Javascript, but that is outside the scope of the support we can provide here.

  7. 7 Posted by alonso.juste on 18 Dec, 2016 02:11 AM

    alonso.juste's Avatar

    Thanks, Damien. I'll try something with js and will post if I find a way to do so.

  8. 8 Posted by alonso.juste on 18 Dec, 2016 12:51 PM

    alonso.juste's Avatar

    After reading many other posts I've found a couple of solutions that might help others:
    1.- I have a big deck with many duplicates and would like to be able to show the duplicated cards with a red background so I can detect them while studying. My cards can have one main tag among many different ones (tag1, tag2, tag3...,tagx) plus the tag 'duplicate' if it is a repeated card. So with each card, under {{Tags}} I will get: 'tagx' or 'tagx duplicate' .

    <script>
    if ("{{Tags}}" == "tag1 duplicate") {
    document.body.style.background = "red";
    } 
    else if ("{{Tags}}" == "tag2 duplicate") {
    document.body.style.background = "red";
    } 
    ---MANY tags later...---
    else if ("{{Tags}}" == "tagx duplicate") {
    document.body.style.background = "red";
    } 
    else {
    document.body.style.background = "#ffffff";
    }
    </script>
    

    2.-Since I have many tags that code would be too long so I have taken another approach. If the string of characters is longer than 4 characters (which is the difference between tagx and tagx duplicate) it will show the card with a red background:

    #Under styles to hide the tags text:
    .none {
      visibility: hidden;
    }
    
    #In the card:
    <div id="s1" class="none">{{Tags}}</div>
    <script>
    var content = document.getElementById("s1").innerHTML;
    if (content.length > 4)  {
        document.body.style.background = "red";
    } 
    </script>
    
  9. Support Staff 9 Posted by Damien Elmes on 18 Dec, 2016 11:55 PM

    Damien Elmes's Avatar

    Thanks for taking the time to post your solution :-)

  10. Damien Elmes closed this discussion on 18 Dec, 2016 11:55 PM.

  11. alonso.juste re-opened this discussion on 26 Dec, 2016 04:28 AM

  12. 10 Posted by alonso.juste on 26 Dec, 2016 04:28 AM

    alonso.juste's Avatar

    I've found some help in reddit, here:
    https://www.reddit.com/r/Anki/comments/5iyvgt/search_for_only_one_t...

    Basically you can also add this in the front card:


    ---all the front card content here---

    And this goes in the style part of the card:
    .duplicate{ background-color: red; }

  13. 11 Posted by alonso.juste on 26 Dec, 2016 04:30 AM

    alonso.juste's Avatar

    I've found some help in reddit, here:
    https://www.reddit.com/r/Anki/comments/5iyvgt/search_for_only_one_t...

    Basically you can also add this in the front card:

    <div class="{{Tags}}">
        ---all the front card content here---
    </div>
    

    And this goes in the style part of the card:

    .duplicate{
        background-color: red; 
    }
    
  14. Support Staff 12 Posted by Damien Elmes on 26 Dec, 2016 08:38 AM

    Damien Elmes's Avatar

    Thanks for taking the time to share your solution.

Comments are closed, but you can start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac