I have a folder full of .txt files and would like to change them to .dat using a method. From what I have researched I have constructed the portion of code below. However, when I run it nothing is changed and they stay as .txt.
def ChangeFileExt(path, curr_ext, new_ext)
with os.scandir(path) as itr:
for entry in itr:
if entry.name.endswith(curr_ext):
name = entry.name.split('.')
name = name + '.' + new_ext
src = os.path.join(path,entry.name)
dst = os.path.join(path,name)
os.rename(src, dst)