def rename(srcpath, destpath, data):
import glob
import os
episodes = sorted(data.keys())
name_pattern = '{date} Showroom - AKB48 no Myonichi Yoroshiku! #{ep} ({name}).mp4'
long_date_pattern = '20{}-{}-{}'
for file in glob.glob('{}/*.mp4'.format(srcpath)):
match = file_re.match(os.path.basename(file))
date = match.groupdict()['date']
long_date = long_date_pattern.format(*[date[i:i+2] for i in range(0, 6, 2)])
new_file = name_pattern.format(
date=date,
ep=episodes.index(long_date)+1,
name=data[long_date]['engName'],
)
os.replace(
file,
'{}/{}'.format(destpath, new_file)
)
评论列表
文章目录