Zipping all subfolders in a folder - Python

39 Views Asked by At

I made a script to zip all subfolders in a specific folder (I want one zip per subfolder) but it seems that shutil doesn't recognize " - " (space/hyphen/space) :

import os
import shutil
path = r"C:\Users\MME106\OneDrive - Compagny\Bureau\Test_py_pdf\Folders"
for folder in os.listdir(path):
    shutil.make_archive(folder, 'zip', path)

it does the job but save the zip files directly in "C:\Users\MME106"

I think there is a problem coming from the path...

I tried also :

path = '"C:\Users\MME106\OneDrive - Company\Bureau\Test_py_pdf\Folders"' => same as with r

path = @"C:\Users\MME106\OneDrive - Company\Bureau\Test_py_pdf\Folders" => doesn't work

0

There are 0 best solutions below