Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7afafa6

Browse filesBrowse files
authored
Add files via upload
1 parent 9136597 commit 7afafa6
Copy full SHA for 7afafa6

File tree

Expand file treeCollapse file tree

1 file changed

+27
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+27
-9
lines changed
Open diff view settings
Collapse file

‎scripts/18_zipper.py‎

Copy file name to clipboardExpand all lines: scripts/18_zipper.py
+27-9Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,36 @@
33
from zipfile import ZipFile
44

55

6-
# set file name and time of creation
6+
# # set file name and time of creation
7+
# today = datetime.now()
8+
# file_name = 'zipper_' + today.strftime('%Y.%m.%dh%H%M') + '.zip'
9+
# dir_name = 'tmp/' # update path
10+
#
11+
#
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+
724
today = datetime.now()
825
file_name = 'zipper_' + today.strftime('%Y.%m.%dh%H%M') + '.zip'
926
dir_name = 'tmp/' # update path
1027

11-
12-
def zipdir(path, zip):
13-
for root, dirs, files in os.walk(path):
28+
def add_folder_to_zip(folderPath,zipFIle):
29+
for root,dirs,files in os.walk(folderPath):
1430
for file in files:
15-
zip.write(os.path.join(root, file))
31+
print(file)
32+
print(root)
33+
full_path=os.path.join.join(root,file)
34+
zipFile.write(full_path)
35+
36+
with ZipFile("test_zip.zip","w") as my_zip:
37+
add_folder_to_zip("Desktop",my_zip)
1638

17-
if __name__ == '__main__':
18-
zipfile = ZipFile(file_name, 'w')
19-
zipdir(dir_name, zipfile)
20-
zipfile.close()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.