Generate folder-subfolders according to olddir

 # https://majing.io/questions/772 

 

import os
from os import walk
import shutil


olddir = './identities_11/'
newdir = './11/'

'''
try:
    os.mkdir(newdir)

except OSError:
    if not os.path.isdir(newdir):
        raise
'''

for (dirpath, dirnames, filenames) in walk(olddir):
    os.mkdir(newdir+dirpath.split('/')[2],0755)

  

posted on 2018-01-24 16:46  cdekelon  阅读(121)  评论(0编辑  收藏  举报

导航