-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathclean_pth.py
30 lines (30 loc) · 987 Bytes
/
clean_pth.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
from fileinput import filename
import os
import sys
base_path = 'output'
g = os.walk(base_path)
file_path_to_delete = []
# candidates = []
# for i in range(50):
# candidates.append(f'ckpt_epoch_{i}.pth')
# for i in range(51, 100):
# candidates.append(f'ckpt_epoch_{i}.pth')
# for i in range(101, 150):
# candidates.append(f'ckpt_epoch_{i}.pth')
# for i in range(151, 200):
# candidates.append(f'ckpt_epoch_{i}.pth')
# for i in range(201, 250):
# candidates.append(f'ckpt_epoch_{i}.pth')
# for i in range(251, 290):
# candidates.append(f'ckpt_epoch_{i}.pth')
for path, dir_list, file_list in g:
for file_name in file_list:
_path = os.path.join(path, file_name)
# for cand in candidates:
# if _path.find(cand) != -1:
# os.remove(_path)
if _path.endswith('.pth') and _path.find('important') == -1:
file_path_to_delete.append(_path)
for name in file_path_to_delete:
os.remove(name)
print('done')