Auto-close old topics from a migrated forum

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:
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

1 Like

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

Can you elaborate more on how?

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!

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

2 Likes

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?

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.

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

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.

I would SSH into the server and then

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 :wink:

12 Likes

Thank You so much, Zogstrip!
:+1:

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

You have helped us a lot.
Thank You!

2 Likes

Once more: Thank You, Zogstrip!

Our server worked hard for one day :hourglass_flowing_sand:and one night :sparkles:

Your tip deserves a tip :gift:

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

2 Likes