import shutil, glob, os
sets = ['train_all', 'test_all']
label_ids = os.listdir('/Users/h1y/Documents/mac2server/echi/echi/labels_all')
old_label_path = '/Users/h1y/Documents/mac2server/echi/echi/labels_all'
new_label_path = '/Users/h1y/Documents/mac2server/echi/echi/labels_train'
image_set = 'train_all',
image_ids = open('/Users/h1y/Documents/mac2server/echi/echi/ImageSets/Main/%s.txt' % (image_set)).read().strip().split()
for label_id in label_ids:
if label_id[:-4] in image_ids:
shutil.copyfile(old_label_path + '/'+label_id, new_label_path+'/'+label_id)