-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles_to_zip.py
More file actions
37 lines (29 loc) · 858 Bytes
/
files_to_zip.py
File metadata and controls
37 lines (29 loc) · 858 Bytes
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
import glob
import os
from os.path import isfile, join, splitext
import zipfile
#run
# C:\Users\Shew\python-3.7.4-embed-amd64\python.exe .\files_to_zip.py
path = '.\\'
pathArcive = path + 'arthives\\'
filesDir = [f for f in os.listdir(path) if isfile(join(path, f))]
for file in filesDir:
if '.py' in file or '.gitignore' in file:
filesDir.remove(file)
for file in filesDir:
if '.zip' in file:
filesDir.remove(file)
for file in filesDir:
if 'check_output_list' in file:
filesDir.remove(file)
# print(filesDir)
for file in filesDir:
name, exten = splitext(file)
nameArchive = path + name + ".zip"
targ = 'w'
if isfile(nameArchive):
targ = 'a'
zip = zipfile.ZipFile(nameArchive,targ)
zip.write(path + file)
zip.close()
print('Done!');