每次清理Xcode都要去刪除好幾個(gè)目錄,感覺(jué)有點(diǎn)麻煩,簡(jiǎn)單寫(xiě)了一個(gè)python腳本.
#!/usr/bin/python
# -*- coding: utf-8 -*-
#coding=utf-8
import os
import shutil
#mac用戶(hù)名
user = 'xxx'
#前綴文件名
prefix = r'/Users/' + user
#指定刪除目錄的集合(http://www.reibang.com/p/225a4b3dd88e)
paths = [
r'/Desktop/zzzzzz',
r'/Library/Developer/Xcode/DerivedData',
r'/Library/Developer/Xcode/iOS DeviceSupport',
r'/Library/Developer/Xcode/Archives',
r'/Library/Developer/Xcode/Products',
r'/Library/Developer/CoreSimulator/Devices',
r'/Library/Developer/XCPGDevices'
]
path = r'/Users/droog/Desktop/zzzzzz'
def del_file(path):
# read all the files under the folder
fileNames = os.listdir(path)
for fileName in fileNames:
c_path = os.path.join(path, fileName)
if os.path.isdir(c_path):
# del_file(c_path)
shutil.rmtree(c_path)
print('delete folder: ' + c_path)
else:
os.remove(c_path)
print('delete file: ' + c_path)
if __name__ == '__main__':
for path in paths:
del_file(prefix + path)
保存腳本內(nèi)容 修改user為mac的用戶(hù)名稱(chēng)大脉,在終端運(yùn)行腳本.