# A few questions about batch moving or deleting topics

**URL:** https://meta.discourse.org/t/a-few-questions-about-batch-moving-or-deleting-topics/88520
**Category:** Support
**Created:** [5월 26, 2018, 7:29오후 UTC](https://meta.discourse.org/t/a-few-questions-about-batch-moving-or-deleting-topics/88520 "2018-05-26T19:29:34Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [5월 26, 2018, 7:29오후 UTC](https://meta.discourse.org/t/a-few-questions-about-batch-moving-or-deleting-topics/88520/1 "2018-05-26T19:29:34Z")

</div>

Hi. I’ve imported data from a phpbb and I’m reworking all the categories.

How do I move or delete all the topics from:

1. One category (well I’m aware of `Topic.where(category_id: XX).update_all(category_id: YY)` but I don’t know how to delete topics this way)?
2. Multiples categories?
3. All the subcategories from a target parent category?

Thank you.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [5월 27, 2018, 12:39오후 UTC](https://meta.discourse.org/t/a-few-questions-about-batch-moving-or-deleting-topics/88520/2 "2018-05-27T12:39:02Z")

</div>

I usually create an array with the category ID that I don’t want and modify the category importer to skip those categories and makes sure that the topic importer skips topics if the category doesn’t exist.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [5월 27, 2018, 1:38오후 UTC](https://meta.discourse.org/t/a-few-questions-about-batch-moving-or-deleting-topics/88520/3 "2018-05-27T13:38:36Z")

</div>

Hi, thank you for your reply.

Which file(s) should I modify? Is such a modification quick and straightforward or does it need work to be functional?

If I can avoid re-importing my forum I’d prefer though.

Also, I noticed that after moving some posts with `Topic.where(category_id: XX).update_all(category_id: YY)` the number of messages was not updated and it seems that it couldn’t be either from sidekiq tasks. Also, it moved the “about this category” topic which can’t be deleted.

I guess this is a more proper way to do so: [https://meta.discourse.org/t/best-way-to-combine-merge-categories-when-importing-topics/21353/6](https://meta.discourse.org/t/best-way-to-combine-merge-categories-when-importing-topics/21353/6) but it doesn’t tell me how to properly delete all messages from a category, just how to move them.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [12월 10, 2020, 10:53오전 UTC](https://meta.discourse.org/t/a-few-questions-about-batch-moving-or-deleting-topics/88520/5 "2020-12-10T10:53:48Z")

</div>



---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [12월 10, 2020, 1:43오후 UTC](https://meta.discourse.org/t/a-few-questions-about-batch-moving-or-deleting-topics/88520/6 "2020-12-10T13:43:58Z")

</div>

해결책은 여기에서 찾을 수 있습니다 👍:

> [@Administrative Bulk Operations](https://meta.discourse.org/t/administrative-bulk-operations/118349):
>
> Below you will find a collection of bulk operations that can be initiated from the command line. You will need SSH access, so if you are a hosted customer, you will need to contact the Discourse team about running these commands. warning Before working with the console it is extremely important that you have a recent backup. Mistakes can always happen! First thing to do is enter your site’s container: cd /var/discourse ./launcher enter app Additional Guides: [Performing bulk actions a…](https://meta.discourse.org/t/performing-bulk-actions-as-a-moderator/272832)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [1월 9, 2021, 1:44오후 UTC](https://meta.discourse.org/t/a-few-questions-about-batch-moving-or-deleting-topics/88520/7 "2021-01-09T13:44:12Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
