linux将大量图片复制到另一个目录,手动实在不方便
import os
from shutil import copyfile
def images_copy(image_origin_path, image_target_path):
if os.path.exists(image_target_path) or not (os.path.exists(image_origin_path)):
print('%s is exited' % image_origin_path)
else:
copyfile(image_origin_path, image_target_path)
print('copy %s is done ' % image_target_path)
其中image_origin_path为源目录图片路径,image_target_path为目标图片路径,比如:
image_origin_path = 'home/cj/origin_img/1.jpg'
image_target_path = 'home/cj/target_img/2.jpg'