You can download this code by clicking the button below.
This code is now available for download.
This code defines a function to compress all files in a specified folder and its subfolders into a single zip file.
Technology Stack : os, zipfile
Code Type : Function
Code Difficulty : Intermediate
def zipfile_create(input_folder, output_zip):
import os
import zipfile
with zipfile.ZipFile(output_zip, 'w') as zipf:
for foldername, subfolders, filenames in os.walk(input_folder):
for filename in filenames:
file_path = os.path.join(foldername, filename)
zipf.write(file_path, arcname=os.path.relpath(file_path, input_folder))