10000 туц Гзвфеу · Brivno1234/python-scripts@132262a · GitHub
[go: up one dir, main page]

Skip to content

Commit 132262a

Browse files
authored
туц Гзвфеу
1 parent 89a2b66 commit 132262a

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

scripts/18_zipper.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,27 @@
99
dir_name = 'tmp/' # update path
1010

1111

12-
def zipdir(path, zip):
12+
# def zipdir(path, zip):
13+
# for root, dirs, files in os.walk(path):
14+
# for file in files:
15+
# zip.write(os.path.join(root, file))
16+
#
17+
# if __name__ == '__main__':
18+
# zipfile = ZipFile(file_name, 'w')
19+
# zipdir(dir_name, zipfile)
20+
# zipfile.close()
21+
22+
23+
today = datetime.now()
24+
file_name = 'zipper_' + today.strftime('%Y.%m.%dh%H%M') + '.zip'
25+
dir_name = 'tmp/' # update path
26+
27+
def add_folder_to_zip(folderPath,zipFile):
1328
for root, dirs, files in os.walk(path):
1429
for file in files:
15-
zip.write(os.path.join(root, file))
30+
print(root)
31+
full_path = os.path.join(root,file)
32+
zipfile.write(full_path)
1633

17-
if __name__ == '__main__':
18-
zipfile = ZipFile(file_name, 'w')
19-
zipdir(dir_name, zipfile)
20-
zipfile.close()
34+
with ZioFile("test_zip.zip","w") as my_zip:
35+
add_folder_to_zip("testFoler8",my_zip)

0 commit comments

Comments
 (0)
0