maxwaitpertransaction=60
fee=0.0005
rpc.setaccount(rpc.getnewadress(),'account0')
rpc.sendtoaddress(getaccountaddress('account'+0),rpc.getbalance(*,10))
while(rpc.getbalance('account0',10)!=rpc.getbalance('account0',0))
(
wait(10)
)
numberofaccounts=0
for (i=0;i
while(rpc.getbalance('account'+i,10)!=rpc.getbalance('account'+i,0))
(
wait(10)
print('.')
)
tosend=(rpc.getbalance(('account'+i,10)-fee)/2)
rand=random(max=tosend/3)
rpc.setaccount(rpc.getnewadress(),'account'+i)
rpc.setaccount(rpc.getnewadress(),'account'+(i+1))
rpc.sendmany<'account'+i>(getaccountaddress('account'+(numberofaccounts+1), tosend+rand,getaccountaddress('account'+(numberofaccounts+2),amounttosend-rand)
numberofaccounts= numberofaccounts+2
wait(random(max= maxwaitpertransaction))
)
i hope getaccountaddress gives the last adress we set to that account, you should check that if you really want to use that code
maybe sending all btc to one adress in first place is not so genius...