#!/usr/bin/python # -*- coding: UTF-8 -*- import os import sys import re import shutil import glob dirNames1 = "./DANGKOU_RR52C_04A" PanelbinDir = "PanelSet_Def" #创建PanelSet_Def文件夹 if os.path.exists(PanelbinDir): shutil.rmtree(PanelbinDir) os.mkdir(PanelbinDir) dirs = os.listdir(dirNames1) for dir in dirs: binPath=glob.glob(dirNames1+"/"+dir+"/PanelSet_Def.bin") binfiles = os.listdir(dirNames1+"/"+dir) for binfile in binfiles: if "PanelSet_Def.bin" in binfile: os.makedirs("./"+binDir+"/"+dir) #可生成多层递归目录 shutil.move(binPath[0],"./"+binDir+"/"+dir) else: continue