# Batch tagging through console

**URL:** https://meta.discourse.org/t/batch-tagging-through-console/47602
**Category:** Support
**Created:** [July 21, 2016, 2:22pm UTC](https://meta.discourse.org/t/batch-tagging-through-console/47602 "2016-07-21T14:22:52Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [July 21, 2016, 2:38pm UTC](https://meta.discourse.org/t/batch-tagging-through-console/47602/2 "2016-07-21T14:38:41Z")

</div>

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.

```plaintext
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

```

---

_[View the full topic](https://meta.discourse.org/t/batch-tagging-through-console/47602)._
