http://www.perlmonks.org?node_id=963452


in reply to Re^4: Rename unreliable on Windows
in thread Rename unreliable on Windows

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.