-
Notifications
You must be signed in to change notification settings - Fork 1
/
zip_commands.py
25 lines (24 loc) · 1019 Bytes
/
zip_commands.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
import zipfile
import os
def unzip(directory):
done = False
to_unzip = [file for file in os.listdir(directory) if file.endswith('.zip')]
for file in to_unzip:
with zipfile.ZipFile(directory+'/'+file, 'r') as zip_ref:
zip_ref.extractall(directory)
try:
directory1 = file.strip('.zip')
to_unzip2 = [file for file in os.listdir() if file.endswith('.zip')]
for file in to_unzip2:
with zipfile.ZipFile(directory1+'/'+file, 'r') as zip_ref:
zip_ref.extractall(directory1)
try:
directory2 = file.strip('.zip')
to_unzip3 = [file for file in os.listdir(directory) if file.endswith('.zip')]
for file in to_unzip3:
with zipfile.ZipFile(directory+'/'+file, 'r') as zip_ref:
zip_ref.extractall(directory)
except:
pass
except:
pass