import os
import shutil

SOURCE_DIR = 'F:/00_group'
SAVE_DIR = 'G:/00_group_cut'

# fopen = open('result.json','r')
# dic = eval(fopen.read())
# fopen.close()
labels = os.listdir(SOURCE_DIR)
print(labels)

for label in labels:
    print(label)
    files = os.listdir(os.path.join(SOURCE_DIR, label))
    print(files)
    for file in files:
        print(file)
        sourceSrcDir = os.path.join(SOURCE_DIR, label, file, 'reports')
        dstSrcDir = os.path.join(SAVE_DIR, label, file, 'reports')
        print(sourceSrcDir, dstSrcDir)
        if os.path.exists(dstSrcDir):
            print('have copied')
            continue
        shutil.copytree(sourceSrcDir, dstSrcDir)
        print('copy finished')

# for root, dirs, files in os.walk(SOURCE_DIR):
#     print(root,dirs,files)


'''
for idx, md5 in enumerate(dic):
    print(idx)
    label = dic[md5]['label']
    if label == None:
        label = 'None'
    dir = dic[md5]['dir']
    if not os.path.exists(os.path.join(SAVE_DIR, label)):
        os.makedirs(os.path.join(SAVE_DIR, label))
    sourceSrcDir = os.path.join(SOURCE_DIR, dir,'reports')
    dstSrcDir = os.path.join(SAVE_DIR, label, dir,'reports')
    print(sourceSrcDir, dstSrcDir)
    if os.path.exists(dstSrcDir):
        print('have copied')
        continue
    shutil.copytree(sourceSrcDir, dstSrcDir)
    print('copy finished')
'''

