in reply to Remote Pipe
Your problem seems to be with the renaming part. You are trying to rename $file.tmp to $file, but since there are no quotes around $file.tmp, the . is acting like the string concatenation operator, so it is looking for Win.initmp instead of Win.ini.tmp. Just put the $file.old and $file.tmp parts of the rename inside double quotes and it should work fine.