Changing the ids of folders from script

Due to copying items (with, I have some objects with spaces in their ids. For some reason, I am not able to change the ids of folders from a script. If I run this script twice, is still 'some thing' instead of 'some-thing'. is (correct) 'some-thing', but even clearing and rebuilding the catalog does not seem to work.

Are there any other (better) ways of doing this, should I use plone.api.rename or something similar instead?

(PS: the content was originally added on another instance (but with same versions/add-ons)

#python 3
#from plone.indexer import indexer

from zope.component.hooks import setSite
from zope.lifecycleevent import modified
import transaction

brains = app.mysite.portal_catalog(portal_type="Folder")

if brains:
	print('Total  objects: ')
	for brain in brains:
		if ' '  in
             obj = brain.getObject()
			 ide =' ', '-')
             print(ide) = ide #update don't use this
             api.content.rename(obj=obj, new_id=ide) #update, use this
			 #tried all combinations of this
			 #and this outside of loop (and also inside, 
             #just to be sure)


Why don‘t use the offcial rename() method instead of hacking something together?

The only docs I found looked like they were for Archetype. Where do I find docs (is the synax obj.rename (or do I need to rename it 'from the parent folder' ?

What has plone.api to do with Archetypes vs. DX?
Nothing. rename() is the official method. That’s why is is called plone.api