Python + + determines whether a file exists from one folder to another folder file copy

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)

0 = NUM
for Fi in the os.listdir (Adir):
      im_name = '0' + Fi [. 1:]
      shutil.copyfile (Adir + Fi, alldir + STR (NUM) + '_' + Fi) the folder # Adir file Fi, are copied to the folder alldir, and rename STR (NUM) + '_' + Fi
      shutil.copyfile (Bdir + im_name, alldir + STR (NUM) + '_' + im_name)
      NUM = NUM . 1 +
      Print (NUM)

Guess you like

Origin www.cnblogs.com/wjjcjj/p/12307095.html