Help with editing existing configurations using scripting

Hi folks,
I want to edit existing settings for MikroTik switch using Scripting (rsc) file. The switch I’m using is RB-2011.

Initial scripting:

/interface bridge
add name=bridge1
/interface bonding
add mode=active-backup name=wan1 slaves=ether1,ether9
/interface bridge port
add bridge=bridge1 interface=ether2
add bridge=bridge1 interface=ether3
add bridge=bridge1 interface=ether4
add bridge=bridge1 interface=ether5
add bridge=bridge1 interface=ether6
add bridge=bridge1 interface=ether7
add bridge=bridge1 interface=ether8

What I want to change: remove ‘ether2’ out of ‘bridge1’ bridge, change slaves of ‘wan1’ bonding to ‘ether1’ & ‘ether2’, then add ‘ether9’ and ‘ether10’ to the ‘bridge1’ bridge.
My code snippet that keeps throwing error:

/interface bridge port
remove bridge=bridge1 interface=ether2
/interface bonding
edit mode=active-backup name=wan1 slaves=ether1,ether2
/interface bridge port
add bridge=bridge1 interface=ether9
add bridge=bridge1 interface=ether10

Thank you!

I don’t think that edit works in scripts, it is interactive, thus command line only.

You can try using the set command, something like:
/interface bonding set [find name=wan1] slaves=ether1, ether2
or - possibly easier - remove the whole bonding and re-add it with the new settings.