import os
import shutil
def copy_by_foldeR(path_A,path_B,del_param=False):
set_lists = set(i.split('.')[0] for i in os.listdir(path_A))
num = 0
for i in set_lists:
print(i)
num = num+1
new_name = '{}{}'.format(num, '.bmp')
print(new_name)
shutil.copy(path_A + "/" + i+'.bmp', path_B + "/" + new_name)
if del_param:
shutil.rmtree(path_A)
if __name__== "__main__" :
path_A='D:\desktop\正常图像' #需要核对的文件夹
path_B='D:\desktop\RR' #需要提取的文件夹集合
if not os.path.exists(path_B):
os.makedirs(path_B)
else:
shutil.rmtree(path_B)
os.makedirs(path_B)
copy_by_foldeR(path_A, path_B, del_param=True)
拷贝图像并重新命名
最新推荐文章于 2024-09-07 20:08:36 发布