指定功能1:实现从指定“第某张”图片开始,从“第某张”图片结束;
指定功能2:实现间隔N个复制一张;
import shutil
import os
#目录自己改一下即可
path = r"X:\XXX\XXXX...." #图片路径
new_path = r"Y:\YYY\YYYY...."#存放路径
"""
宏参数(也可以define)
"""
where_start = 19#从第几张图片开始
where_end = 1519#从第几张图片结束
space = 20 #间隔数
"""
开始程序
"""
count = where_start
start = 0
choose = 0
for file in os.listdir(path):
if start != where_start:
print("pass:not start")
start = start+1
continue
if (choose%space != 0):
print("pass:not need")
choose += 1
count+=1
continue
choose += 1
full_file = os.path.join(path, file)
new_full_file = os.path.join(new_path, file)
shutil.copy(full_file, new_full_file)
if count == where_end:
print("done")
break
count += 1
print(count)
print("complete!")
结果: