Skip to content

Commit 44b9297

Browse files
committed
original
1 parent aec08c9 commit 44b9297

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

ProcessMSFace.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
# -*-coding:utf-8 -*-
2-
import os.path
3-
import shutil
4-
5-
def getFileList(dirName):
6-
imgList = os.listdir(dirName)
7-
if 'Thumbs.db' in imgList:
8-
imgList.remove('Thumbs.db')
9-
return imgList
10-
11-
def DeleteFolderLessThanThresh(rootDir, threshValue = 10):
12-
recordArr = []
13-
for parent, dirNames, fileNames in os.walk(rootDir):
14-
if len(dirNames) == 0:
15-
break
16-
else:
17-
for dirName in dirNames:
18-
imageList = getFileList(os.path.join(parent, dirName))
19-
if len(imageList) <= threshValue:
20-
str_tmp = dirName + "\t" + str(len(imageList)) + '\n'
21-
recordArr.append(str_tmp)
22-
shutil.rmtree(os.path.join(parent, dirName))
23-
if len(recordArr) != 0:
24-
savePathName = 'DeleteFolderLessThanThresh.txt'
25-
with open(savePathName, 'w') as train_fid:
26-
train_fid.writelines(recordArr)
27-
28-
if __name__ == '__main__':
29-
actionType = 1
30-
root_dir = r"D:\test - 1"
31-
if actionType == 1:
32-
DeleteFolderLessThanThresh(root_dir, 10)
33-
else:
34-
print "other thing to be done"
35-
print "hahaha"
1+
# -*-coding:utf-8 -*-
2+
import os.path
3+
import shutil
4+
5+
def getFileList(dirName):
6+
imgList = os.listdir(dirName)
7+
if 'Thumbs.db' in imgList:
8+
imgList.remove('Thumbs.db')
9+
return imgList
10+
11+
def DeleteFolderLessThanThresh(rootDir, threshValue = 10):
12+
recordArr = []
13+
for parent, dirNames, fileNames in os.walk(rootDir):
14+
if len(dirNames) == 0:
15+
break
16+
else:
17+
for dirName in dirNames:
18+
imageList = getFileList(os.path.join(parent, dirName))
19+
if len(imageList) <= threshValue:
20+
str_tmp = dirName + "\t" + str(len(imageList)) + '\n'
21+
recordArr.append(str_tmp)
22+
shutil.rmtree(os.path.join(parent, dirName))
23+
if len(recordArr) != 0:
24+
savePathName = 'DeleteFolderLessThanThresh.txt'
25+
with open(savePathName, 'w') as train_fid:
26+
train_fid.writelines(recordArr)
27+
28+
if __name__ == '__main__':
29+
actionType = 1
30+
root_dir = r"D:\test - 1"
31+
if actionType == 1:
32+
DeleteFolderLessThanThresh(root_dir, 10)
33+
else:
34+
print "other thing to be done"
35+
print "hahaha"

0 commit comments

Comments
 (0)