> For the complete documentation index, see [llms.txt](https://gautamnaik1994.gitbook.io/snippets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gautamnaik1994.gitbook.io/snippets/terminal/zip-all-files.md).

# Zip All Files

```python
import zipfile
import os

zip_path = "all_files.zip"

with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
    for root, dirs, files in os.walk("."):
        for file in files:
            file_path = os.path.join(root, file)

            # Avoid zipping the zip file itself if re-run
            if file_path == "./all_files.zip":
                continue

            # Preserve folder structure inside the zip
            zipf.write(file_path)
```
