Well this was easily solved. Just export everything by using Special:Export (Special:AllPages can filter by namespace). You can then parse the exported file and change for instance the content between each <title>
tag to whatever you want. For example the name of the namespace or subpage you want to transfer the content to.
When you're done you just import it back by using Special:Import.