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

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.

1 Like