... or maybe something more complicated to make sure the wallet encryption/writing completed OK before removing the wallet.dat. Like checking to make sure wallet.dat.aes256's filesize doesn't get smaller through the decrypt...use...re-encrypt cycle.
thanks for having a look. I updated the script, with something a bit more complicated, but perhaps better than filesize:
the wallet is decrypted one last time, and I check it is a fixed point before deleting it.