How can I run multiple rake posts:remap at once?

AI-generated summary

The original poster, hiccup, is seeking help with two issues related to running rake tasks in Discourse. Firstly, they want to know how to run multiple rake posts:remap tasks at once, as they have over 1000 tasks to perform. Secondly, they want to use Regex Remap to remove text from the end of URLs that have it.

In response, pfaffman suggests two possible approaches. If the forum is still in development and has not gone live, the issue could be addressed in the import script by wiping the database and starting again. If the forum is already live, the issue should be tackled in Rails, as it would be too complicated to do so in a rake task.

Hey
I have two questions if you can help I will be grateful for that

1: I have multiple rake posts:remap more than 1000

Example:

rake posts:remap["https://demo.com/?p=100041115","https://www.discourse.com/t/14529"]
rake posts:remap["https://demo.com/?p=100041158","https://www.discourse.com/t/14530"]
rake posts:remap["https://demo.com/?p=100041181","https://www.discourse.com/t/14531"]
rake posts:remap["https://demo.com/?p=100041222","https://www.discourse.com/t/14532"]
rake posts:remap["https://demo.com/?p=100041280","https://www.discourse.com/t/14533"]
rake posts:remap["https://demo.com/?p=100041321","https://www.discourse.com/t/14534"]
rake posts:remap["https://demo.com/?p=100041556","https://www.discourse.com/t/14535"]
rake posts:remap["https://demo.com/?p=100041629","https://www.discourse.com/t/14536"]
rake posts:remap["https://demo.com/?p=100041642","https://www.discourse.com/t/14537"]
rake posts:remap["https://demo.com/?p=100041745","https://www.discourse.com/t/14538"]

How can I run all of them at once?

2: how can I use Regex Remap?

to remove the text in all URLs that have text at the end like this one

https://demo.com/?p=100041115/text-text

To be like this

https://demo.com/?p=100041115

just remove the text at the end of this URLS

Thank you.

If it’s not too late (your forum has not yet gone live and people are not yet adding new data), your want to do that in your import script. Just wipe the database and start again.

If it is too late (you’ve already launched your forum in discourse) you’ll want to do it in rails. It’s too hard to do it in a take task because of figuring out all the layers of escaping special characters.