修改下面的python3代码如果同名文件存在则不移动import shutilosresysfile_type =m3u8num = 0new_path= rE下载avefor derName subfolders filenames in oswalkrD用户目录下载 for i in rangelenfilenames if filenamesiendswithfile_t
import shutil,os,re,sys
file_type =('.m3u8') num = [0] new_path= r'E:\下载\ave' for derName, subfolders, filenames in os.walk(r'D:\用户目录\下载'): for i in range(len(filenames)): if filenames[i].endswith(file_type): file_path=derName+'/'+filenames[i] newpath=new_path+'/'+filenames[i] if not os.path.exists(newpath): # 判断文件是否存在 shutil.move(file_path,newpath) num[0] += 1 print("完成", num[0])
原文地址: https://www.cveoy.top/t/topic/bTdG 著作权归作者所有。请勿转载和采集!