-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProcessMSFace.py
More file actions
35 lines (32 loc) · 1.15 KB
/
ProcessMSFace.py
File metadata and controls
35 lines (32 loc) · 1.15 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
# -*-coding:utf-8 -*-
import os.path
import shutil
def getFileList(dirName):
imgList = os.listdir(dirName)
if 'Thumbs.db' in imgList:
imgList.remove('Thumbs.db')
return imgList
def DeleteFolderLessThanThresh(rootDir, threshValue = 10):
recordArr = []
for parent, dirNames, fileNames in os.walk(rootDir):
if len(dirNames) == 0:
break
else:
for dirName in dirNames:
imageList = getFileList(os.path.join(parent, dirName))
if len(imageList) <= threshValue:
str_tmp = dirName + "\t" + str(len(imageList)) + '\n'
recordArr.append(str_tmp)
shutil.rmtree(os.path.join(parent, dirName))
if len(recordArr) != 0:
savePathName = 'DeleteFolderLessThanThresh.txt'
with open(savePathName, 'w') as train_fid:
train_fid.writelines(recordArr)
if __name__ == '__main__':
actionType = 1
root_dir = r"D:\test - 1"
if actionType == 1:
DeleteFolderLessThanThresh(root_dir, 10)
else:
print "other thing to be done"
print "hahaha"