最近研究使用脚本copy文件
def copyFiles(sourceDir, targetDir):
for f in os.listdir(sourceDir):
sourceF = os.path.join(sourceDir, f)
targetF = os.path.join(targetDir, f)
if os.path.isfile(sourceF):
#创建目录
if not os.path.exists(targetDir):
os.makedirs(targetDir)
print(sourceF)
print(targetF)
#文件不存在,或者存在但是大小不同,覆盖
if not os.path.exists(targetF) or (os.path.exists(targetF) and (os.path.getsize(targetF) != os.path.getsize(sourceF))):
#2进制文件
# open(targetF, "wb").write(open(sourceF, "rb").read())
shutil.copyfile(sourceF, targetF)
if os.path.isdir(sourceF):
copyFiles(sourceF, targetF)
def copyFrameworks():
addressOfFrameworks = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + "/Carthage/Build/iOS/Static"
if not os.path.exists(addressOfFrameworks) :
addressOfFrameworks = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + "/Carthage/Build/iOS"
f_list = os.listdir(addressOfFrameworks)
for fileNAME in f_list:
print(fileNAME)
if os.path.splitext(fileNAME)[1] == '.framework':
oldname = addressOfFrameworks + "/" + fileNAME
print(oldname)
newname = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + "/Frameworks" + "/" + fileNAME
print(newname)
# shutil.copyfile(oldname, newname)
copyFiles(oldname,newname)