Python batch-rename script sending files to root folder -
ok, weird , maybe awkward. made script change end of subtitles files keep consistency. replaces a.x.str a.y.str. worked flawlessly @ single folder.
i decided make recursive version of on folder had, regardless if episodes together, separated season or each on individual path.
i don't know how or why, sent files reached root folder using until halted raising fileexistserror.
the code bit i'm using is:
def rewrite(folder, old, new): f in next(os.walk(folder))[2]: os.rename(os.path.join(folder, f), os.path.join(path, f.replace(old, new))) f in next(os.walk(folder))[1]: x = os.path.join(folder, f) rewrite(x, old, new)
where 'old' "a.x.str", 'new' "a.y.str" , folder full path of root folder "c:\series\serie name".
why doesn't work recursive? first bit of code (first loop) works fine on it's own in single folder. problem "next" use names of files , folders?
the code showing using path
variable in rename destination -- should folder
variable instead.
Comments
Post a Comment