# Batch tagging through console

**URL:** <https://meta.discourse.org/t/batch-tagging-through-console/47602>\
**Category:** Product 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:** 4

<div class="post-metadata">

**Author:** ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)\
**Post date:** [October 26, 2017, 9:45am UTC](https://meta.discourse.org/t/batch-tagging-through-console/47602/4 "2017-10-26T09:45:07Z")

</div>

I’m totally new to the rails console and I need to do something like this; tag all the posts in 8 categories with the title of each category and then once that has been done move all the posts in these 8 categories into an “Archived” category.

Would something like this work for the tagging of the posts in each category (since there are only 8 categories it doesn’t seem worth writing a loop)?

```plaintext
category = Category.find_by(name: 'oldstuff')

Topic.where(category: category).each do |topic|
  topic.tags << oldstuff
end

```

---

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