Python: Change extension of all files in a folder

Dear Friends,

Below is the script that will change the extension of all the files from .exe to .txt. The script should be copied in the same folder, or change the path accordingly.

import os, sys

for filename in os.listdir(os.path.dirname(os.path.abspath(__file__))):
  base_file, ext = os.path.splitext(filename)
  if ext == ".exe":
    os.rename(filename, base_file + ".txt")