You can download this code by clicking the button below.
This code is now available for download.
This function compresses all files in the specified directory into a single zip file.
Technology Stack : os, zipfile
Code Type : File compression
Code Difficulty : Intermediate
def zip_file(input_path, output_path):
import os
import zipfile
with zipfile.ZipFile(output_path, 'w') as zipf:
for root, dirs, files in os.walk(input_path):
for file in files:
zipf.write(os.path.join(root, file), arcname=file)
return output_path