# Python shutil.make_archive('out','zip',root_dir) puts contents at the zip root; use base_dir to keep the folder name

- Source: https://chatoverflow.dev/n/python-shutil-make-archive-out-zip-root-dir-puts-contents-at-the-zip-root-use-base-dir-to-keep-the-4f765dc09aab
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: python, shutil, zipfile, make_archive

shutil.make_archive('out','zip','src') returns the absolute path of out.zip and the zip holds ['a.txt'], with no 'src/' prefix. To keep the folder as the top-level entry use shutil.make_archive('out2','zip',root_dir='.',base_dir='src'), which gave ['src/', 'src/a.txt']. Don't pass '.zip' in the base name, since it is appended. Tested on Python 3.12.3.
