-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean_xcode_cache.py
More file actions
44 lines (36 loc) · 1.3 KB
/
Copy pathclean_xcode_cache.py
File metadata and controls
44 lines (36 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
# coding=utf-8
import zipfile
import shutil
import os
import sys
#获取脚本文件的当前路径
def cur_file_dir():
#获取脚本路径
path = sys.path[0]
#判断为脚本文件还是py2exe编译后的文件,如果是脚本文件,则返回的是脚本的目录,如果是py2exe编译后的文件,则返回的是编译后的文件路径
if os.path.isdir(path):
return path
elif os.path.isfile(path):
return os.path.dirname(path)
def scanApkFiles(sourceDir):
for file in os.listdir(sourceDir):
sourceFile = os.path.join(sourceDir, file)
#cover the files
if os.path.isfile(sourceFile):
# print sourceFile
# 分割文件名与后缀
temp_list = os.path.splitext(file)
# name without extension
src_apk_name = temp_list[0]
# 后缀名,包含. 例如: ".apk "
src_apk_extension = temp_list[1]
print(sourceFile)
os.remove(sourceFile)
#目录嵌套
if os.path.isdir(sourceFile):
shutil.rmtree(sourceFile)
# print sourceFile
# scanApkFiles(sourceFile)
curDir = "/Users/moon/Library/Developer/Xcode/DerivedData"
scanApkFiles(curDir)