One of the solutions that you could use in conjunction with your script is Unlocker. Although the screen shots highlight the GUI, there's also a command line version. If you used that, your script should then be able to do the rename.
In reply to Re^5: Rename unreliable on Windows
by Sinistral
in thread Rename unreliable on Windows
by elef
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |