Ionic - Update Android and iOS App Id with script

I would like to be able to update the app Id in Android and iOS when I change the app Id in the capacitor.config.json or run a script.

Basically I am building multiple variations of the same app with different app Ids. I do not want to update these manually or delete and rebuild the entire Android/iOS projects (I am doing this currently and I lose code I have changed in the native projects). I need to be able to switch back and forth between the App Ids.

Is there any way to do this?