增加代码如下:

对output_dir目录下文件进行多次重新命名的处理

for file in glob.glob(os.path.join(output_dir, '*.mp4')): if 'h_' in os.path.splitext(os.path.basename(file))[0]: new_name = os.path.splitext(os.path.basename(file))[0].replace('h_', '') new_name = new_name.split('_', 1)[1] + os.path.splitext(os.path.basename(file))[1] os.rename(file, os.path.join(output_dir, new_name))

请对代码单独增加对output_dir目录下文件进行多次重新命名的处理:如果命名中包含h_则删除h_然后对目录下文件进行第二次命名处理:删除第一个英文字母前的数字和mp4后缀前的第一个英文字母import osimport globfrom natsort import natsorteddir_path = rEhomeupoutput_dir = rEhomeup1# 当前文件夹下的所有mp4

原文地址: http://www.cveoy.top/t/topic/dd1v 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录