-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract7z.py
83 lines (56 loc) · 1.67 KB
/
extract7z.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
# coding: utf-8
# In[1]:
#!/usr/bin/python3
# coding: utf-8
import os
import os.path
#import json
#import random
#import pickle
import time
#import subprocess
#import os
#import subprocess,signal
# In[2]:
contents = 'B:\\baidu\\0000动画\\'
ex_contents = 'B:\\baidu\\动画_extracted\\'
print(contents)
print(len(contents))
# In[3]:
import py7zr
# In[ ]:
s =[]
for root, dirs, files in os.walk(contents):
for name in files:
if ('7z' in name )and ('downloading' not in name ) :
#print(f'neme ={name}')
#print(f'root ={root}')
a_ = root[len(contents):]
a2_ = a_.split('\\')
PASSWORD1_ = a2_[0]
print(f'password ={PASSWORD1_}')
PATH2_ = a2_[1:]
PATH2str = '\\'.join(PATH2_)
#print(f'path2 = {PATH2str}')
#print(a2_)
ex_dir = root +"\\"
print(f'exdir={ex_dir}')
FILENAME1_ = root +'\\'+ name
print(f'filename ={FILENAME1_}')
#print(f'dirs ={dirs}')
#print(f'files ={files}')
#s.append(os.path.join(root, name))
#解压流程
try:
with py7zr.SevenZipFile(FILENAME1_, "r", password=PASSWORD1_) as szf:
cc2 = szf.getnames()
print(f'正在解压{cc2}')
szf.extractall(path = ex_dir)
print(f'解压成功{cc2}')
print(f'删除文件{FILENAME1_}')
os.remove(FILENAME1_)
except:
print(f'错误{FILENAME1_}')
pass
# In[ ]: