linux - Zip all subdirectories using python -


i attempting create script zips of subdirectories of folder, deletes folders have been zipped

import shutil import os loc = "foldertzipfilesin" path = "/whereparentis/" + loc + "/" dirs = os.listdir( path ) file in dirs:    name =  file    shutil.make_archive(name, 'zip', path)    shutil.rmtree(name) 

it seems run, not create zip files. thanks

probably issue path you're passing argument.

i've tried script following changes:

import shutil import os loc = "testfolder" path = os.getcwd() + '/' +  loc + "/" dirs = os.listdir( path ) file in dirs:    name =  file    shutil.make_archive(name, 'zip', path) 

and worked creating zip files every file in loc folder. files created on path you've ran script.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -