import glob, os # point path to directory containing the shows # load episode titles into `ep.txt` path = r"I:\Videos\show" new_filenames = [] with open(path + '\\ep.txt', 'r') as f: for line in f: new_filenames.append(line) fileglob = glob.glob(path + '\\*') fileglob.remove(path + '\\ep.txt') for i in range(len(fileglob)): ext = os.path.splitext(fileglob[i])[1] new_name = path + '\\' + new_filenames[i].strip() + ext print(fileglob[i] + ' -> ' + new_name) try: os.rename(fileglob[i], new_name) except: continue