import os
import shutil
Adir = './trainA0/'
Bdir = './trainB0/'
alldir = './all/'
if not os.path.exists(Adir):
print ("The source path trainA0 is not exist")
if not os.path.exists(Bdir):
print ("The source path trainB0 is not exist")
if not os.path.exists(alldir):
os.mkdir(alldir)
num=0
for fi in os.listdir(Adir):
im_name = '0' + fi[1:]
shutil.copyfile(Adir+fi,alldir+str(num)+'_'+fi) #把文件夹Adir中的文件fi,复制到文件夹alldir中,并重新命名为str(num)+'_'+fi
shutil.copyfile(Bdir+im_name,alldir+str(num)+'_'+im_name)
num = num + 1
print (num)