#!/usr/bin/python
import glob
import os
from pathlib2 import Path

dir_list = []
p = "/Volumes/engineering/media/Television"
for directory in [str(item) for item in Path(p).rglob(".")]:
    if 'Season' in directory:
        dir_list.append(directory)

for directory in dir_list:
    file_list = os.walk(directory)
    for filelist in file_list:
        flist = filelist[2]
        for filename in filelist[2]:
            fname = str.encode(filename)
            if str.encode('tvrenametemp') in fname:
                oldfile = f'{directory}/{filename}'
                newfile = f'{directory}/{filename.replace(".tvrenametemp","")}'
                print(f'Renaming {newfile} to {newfile}')
                os.rename(oldfile, newfile)

exit()