# Auto-close old topics from a migrated forum

**URL:** https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448
**Category:** Migration
**Tags:** rails-console
**Created:** [2월 20, 2015, 1:46오후 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448 "2015-02-20T13:46:35Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![rodrigofarcas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rodrigofarcas/32/69085_2.png) [@rodrigofarcas](https://meta.discourse.org/u/rodrigofarcas)
#### Post date: [2월 20, 2015, 1:46오후 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/1 "2015-02-20T13:46:35Z")

</div>

We migrated to Discourse from another forum software, and I want to close a batch of old topics at once.

I’ve tried using the forum setting for auto-close:

> **[2015-02-20\_1043](https://app.screencast.com/LsF3MSal6hlBa)**
>
> World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.

But this seems not to be affecting migrated old topics, as they are still open. How can I achieve this? (want to close all topics which are older than 720 hours=30 days)

Thanks

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2월 20, 2015, 2:47오후 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/2 "2015-02-20T14:47:34Z")

</div>

You’ll need to do that via the rails console.

---

<div class="post-metadata">

### Author: ![rodrigofarcas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rodrigofarcas/32/69085_2.png) [@rodrigofarcas](https://meta.discourse.org/u/rodrigofarcas)
#### Post date: [2월 20, 2015, 2:59오후 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/3 "2015-02-20T14:59:18Z")

</div>

Can you elaborate more on how?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [2월 21, 2015, 3:14오전 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/4 "2015-02-21T03:14:10Z")

</div>

Click the “menu” icon next to the Topic column header, select the topics to close, click the wrench in the upper right, and select “Close Topics” in the Bulk Actions menu.

@zogstrip console not required!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2월 21, 2015, 3:34오전 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/5 "2015-02-21T03:34:09Z")

</div>

That is true, but will be painful with more than a few screens worth of topics…

---

<div class="post-metadata">

### Author: ![sanderteamspywarefri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sanderteamspywarefri/32/47931_2.png) [@sanderteamspywarefri](https://meta.discourse.org/u/sanderteamspywarefri)
#### Post date: [11월 11, 2015, 10:11오후 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/6 "2015-11-11T22:11:44Z")

</div>

> [@rodrigofarcas](#):
>
> We migrated to Discourse from another forum software, and I want to close a batch of old topics at once.
> 
> I’ve tried using the forum setting for auto-close:[2015-02-20\_1043 - TechSmith Screencast](http://screencast.com/t/FAoaOmK3ru)
> 
> But this seems not to be affecting migrated old topics, as they are still open. How can I achieve this? (want to close all topics which are older than 720 hours=30 days)
> 
> Thanks

I’m in the same situation, but have around 24000 topics to close manually.  
We moved to Discourse software 3 weeks ago.

Manually I have now closed old topics from the years 2003 and 2004.

I still have to manually close old topics from the years  
2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 and 2015.

Quite a big job ahead of me… !!!

Is there an easier way to do this job?

---

<div class="post-metadata">

### Author: ![sanderteamspywarefri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sanderteamspywarefri/32/47931_2.png) [@sanderteamspywarefri](https://meta.discourse.org/u/sanderteamspywarefri)
#### Post date: [11월 11, 2015, 11:06오후 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/7 "2015-11-11T23:06:36Z")

</div>

Maybe the number of old topics I have to close manually is much bigger than I have thought.

The exact number for January 2005 was 820.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [11월 11, 2015, 11:11오후 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/8 "2015-11-11T23:11:08Z")

</div>

> [@sanderteamspywarefri](#):
>
> Is there an easier way to do this jo

I would use the rails console to close all the old topics.

---

<div class="post-metadata">

### Author: ![sanderteamspywarefri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sanderteamspywarefri/32/47931_2.png) [@sanderteamspywarefri](https://meta.discourse.org/u/sanderteamspywarefri)
#### Post date: [11월 12, 2015, 12:13오전 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/9 "2015-11-12T00:13:30Z")

</div>

Thank You for your reply, Zogstrip.

I do not know the console You are referring to.

I have been clicking the radio buttons to select the unclosed topics and then using the close batch function in the “wrench-tool”.

But my experience with this function is, that I regularly gets an error-message if choosing more than 40 to 50 topics to close at one time.

So its very elaborate to close thousands of topics, 30 at a time.

 ![](https://global.discourse-cdn.com/meta/original/3X/3/8/388cda55f958516e2e3369e018971b68c5b57128.png) ![](https://global.discourse-cdn.com/meta/original/3X/2/f/2f9088e325fd54e01b127322807b7c2dddcc8892.png) ![](https://global.discourse-cdn.com/meta/original/3X/c/1/c1faa01ced7f65d79d423be7d3156d2af3bab186.png) ![](https://global.discourse-cdn.com/meta/original/3X/7/f/7f033a2603fe881cee1c3b55c56accc1c57e3e2e.png)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [11월 12, 2015, 9:07오전 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/10 "2015-11-12T09:07:13Z")

</div>

I would SSH into the server and then

```plaintext
cd /var/discourse
./launcher enter app
rails c
Topic.where(closed: false).where("created_at < '2015-01-01'").find_each do |topic| 
  topic.update_status("closed", true, Discourse.system_user)
end

```

And you should have all the topics created **before** January 1st 2015 closed 😉

---

<div class="post-metadata">

### Author: ![sanderteamspywarefri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sanderteamspywarefri/32/47931_2.png) [@sanderteamspywarefri](https://meta.discourse.org/u/sanderteamspywarefri)
#### Post date: [11월 12, 2015, 10:10오전 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/11 "2015-11-12T10:10:20Z")

</div>

Thank You so much, Zogstrip!  
👍

I’ve shown Your tip to our serveradministrator, and he’ll take action.

You have helped us a lot.  
Thank You!

---

<div class="post-metadata">

### Author: ![sanderteamspywarefri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sanderteamspywarefri/32/47931_2.png) [@sanderteamspywarefri](https://meta.discourse.org/u/sanderteamspywarefri)
#### Post date: [11월 13, 2015, 8:55오후 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/12 "2015-11-13T20:55:00Z")

</div>

Once more: Thank You, Zogstrip!

Our server worked hard for one day ⏳and one night ✨

Your tip deserves a tip 🎁

It saved me and my fingers from thousands and thousands and thousands of clicks.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [11월 16, 2015, 9:47오전 UTC](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/13 "2015-11-16T09:47:03Z")

</div>


