-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeal_file.py
45 lines (39 loc) · 1.06 KB
/
deal_file.py
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
45
import os
# import matplotlib.pyplot as plt
# import cv2
# path = '/Users/apple/Downloads/PIC'
# dir_lists = []
# file_lists = []
#
# files = os.listdir(path)
# for f in files:
# if os.path.isdir(path+'/'+f):
# if f[0]!='.':
# dir_lists.append(path+'/'+f)
#
# for d in dir_lists:
# files = os.listdir(d)
# for f in files:
# if os.path.isfile(d+'/'+f):
# if (f[0]!='.')&(f[-1]=='g'):
# file_lists.append(d+'/'+f)
# print file_lists
# pic = cv2.imread(file_lists[0])
# pic = cv2.cvtColor(pic,cv2.COLOR_BGR2RGB)
# plt.imshow(pic)
# plt.show()
def get_files(path):
dir_lists = []
file_lists = []
files = os.listdir(path)
for f in files:
if os.path.isdir(path + '/' + f):
if f[0] != '.':
dir_lists.append(path + '/' + f)
for d in dir_lists:
files = os.listdir(d)
for f in files:
if os.path.isfile(d + '/' + f):
if (f[0] != '.') & (f[-1] == 'g'):
file_lists.append(d + '/' + f)
return file_lists