import os import json from os import error, listdir from os.path import isfile, join onlyfiles = [f for f in listdir("C:\\Users\\EGEMEN\\Downloads\\d")] for x in onlyfiles: if x.startswith("data"): y = x.split("data") os.rename(r'C:\\Users\\EGEMEN\\Downloads\\d\\' + x, r'C:\\Users\\EGEMEN\\Downloads\\d\\' + y[1])