# Ajouter une balise en masse sans effacer les balises existantes

**URL:** https://meta.discourse.org/t/adding-a-tag-in-bulk-without-erasing-existing-tags/50709
**Category:** Support
**Created:** [Septembre 27, 2016, 8:47 UTC](https://meta.discourse.org/t/adding-a-tag-in-bulk-without-erasing-existing-tags/50709 "2016-09-27T08:47:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![alehandrof](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alehandrof/32/119526_2.png) [@alehandrof](https://meta.discourse.org/u/alehandrof)
#### Post date: [Septembre 27, 2016, 8:47 UTC](https://meta.discourse.org/t/adding-a-tag-in-bulk-without-erasing-existing-tags/50709/1 "2016-09-27T08:47:08Z")

</div>

I need to add a tag in bulk without erasing existing tags. I’m aware of the current limitations:

> [@Bulk Actions: "Add Tags" in addition to "Change Tags"](https://meta.discourse.org/t/bulk-actions-add-tags-in-addition-to-change-tags/40059):
>
> Today I made the rather sad discovery that the bulk “change tags” feature depicted below actually will set the tags for selected topics to be exactly the same as the tags entered, meaning it will remove any existing tags. Discovery is sad because I accidentally borked 20 or more topic tags because I misunderstood what was going to happen, and there’s no undo. crying_cat_face A fix to this would be to add a new “Add Tags” option to the bulk actions, which would allow the bulk adding of tags to…

Is there a Ruby/console solution?

All the topics belong to the “Events/Conf 2016” sub-category and I want to tag them with “conf-2016”.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [Septembre 27, 2016, 3:14 UTC](https://meta.discourse.org/t/adding-a-tag-in-bulk-without-erasing-existing-tags/50709/2 "2016-09-27T15:14:02Z")

</div>

Something like this:

> [@Batch tagging through console](https://meta.discourse.org/t/batch-tagging-through-console/47602/2):
>
> Something quick that I think will work. Might want to verify against a couple of records first before uncommenting the line to add the tag. tag = Tag.find\_by(name: 'soundcloud') category = Category.find\_by(name: 'music') Topic.where(category: category).each do |topic| if topic.first\_post.raw =~ /\<your keyword here\>/ puts topic.first\_post.raw # topic.tags \<\< tag end end

---

<div class="post-metadata">

### Author: ![alehandrof](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alehandrof/32/119526_2.png) [@alehandrof](https://meta.discourse.org/u/alehandrof)
#### Post date: [Février 8, 2017, 5:57 UTC](https://meta.discourse.org/t/adding-a-tag-in-bulk-without-erasing-existing-tags/50709/3 "2017-02-08T17:57:19Z")

</div>

Perfect. Thank you!

Sorry I didn’t reply much, much earlier. I was preoccupied with other work. But I’m now making my way through my backlog of Discourse issues 🙂

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [Juin 8, 2024, 12:45 UTC](https://meta.discourse.org/t/adding-a-tag-in-bulk-without-erasing-existing-tags/50709/4 "2024-06-08T12:45:01Z")

</div>

Ce sujet a été automatiquement fermé après 2811 jours. Les nouvelles réponses ne sont plus autorisées.
