in reply to
File Extension Renaming
Also note, to prevent possible errors and data loss, you should make sure your renaming operation does not introduce unintended naming collisions.
For example, if your directory already has a file called "foobar.txt", what does your program do when it encounters the file "foobar.log"? Some of the code listed above handles this issue, but it does well to expressly understand this and figure out how you want to handle it.