38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
from re import sub
|
|
import os,sys,io,shutil
|
|
def redUuid():
|
|
with open('d:/project/DB/DragonBall_5/tools/new.txt', 'r') as f:
|
|
data = f.readlines()
|
|
dataMat = [];
|
|
srcPath = 'd:\\project\\DB\\DragonBall_5\\build\\DragonBall5\\res'
|
|
desPath = 'd:\\project\\DB\\DragonBall_5\\tools\\minizip\\res'
|
|
for line in data:
|
|
curline = line.strip().split("/")
|
|
uuid = curline[-1].split(".")
|
|
findSrcFile(srcPath,uuid[0],desPath)
|
|
|
|
def findSrcFile(srcPath,uuid,desPath):
|
|
for filenames in os.listdir(srcPath):
|
|
#取得文件或文件名的绝对路径
|
|
filepath = os.path.join(srcPath,filenames)
|
|
destinationpath = os.path.join(desPath,filenames)
|
|
#判断是否为文件夹
|
|
if os.path.isdir(filepath):
|
|
isExists=os.path.exists(destinationpath)
|
|
if not isExists:
|
|
os.makedirs(destinationpath)
|
|
#如果是文件夹,重新调用该函数
|
|
findSrcFile(filepath,uuid,destinationpath)
|
|
#判断是否为文件
|
|
elif os.path.isfile(filepath):
|
|
#如果该文件的后缀为用户指定的格式,则把该文件复制到用户指定的目录
|
|
#print(uuid)
|
|
file = filenames.split(".")
|
|
if uuid == file[0]:
|
|
#给出提示信息
|
|
print('Copy %s'% filepath +' To ' + desPath)
|
|
#复制该文件到指定目录
|
|
shutil.copy(filepath,desPath)
|
|
return
|
|
|
|
redUuid() |