I want to change a.txt to b.kml.
a.txt
b.kml
File may be inside a directory, in that case specify the path:
import os old_file = os.path.join("directory", "a.txt") new_file = os.path.join("directory", "b.kml") os.rename(old_file, new_file)