0

I am zipping a folder in python like

mypath = "c:\Test\mypath"
foldername = "mydata"
zipf = zipfile.ZipFile(foldername + '.zip', 'w', zipfile.ZIP_DEFLATED)
zipdir(mypath, zipf)
zipf.close()

the output of zipped file mydata.zip is located at mypath "c:\Test\mypath\mydata.zip" But i want mydata.zip file into another folder like "c:\Test\mypath\anotherfolder\mydata.zip"

Please help me to do achieve this.

Jack
  • 21
  • 1
  • 6

1 Answers1

0

The zip file is created in the current working directory. that is "c:\Test\mypath" To achieve my requirement, I changed the current working directory using os.chdir() as "c:\Test\mypath\anotherfolder" and got the zip file in the same location

mypath = "c:\Test\mypath"
foldername = "mydata"
anotherpath = "c:\Test\mypath\anotherfolder"
os.chdir(anotherpath)
zipf = zipfile.ZipFile(foldername + '.zip', 'w', zipfile.ZIP_DEFLATED)
zipdir(mypath, zipf)
zipf.close()
Jack
  • 21
  • 1
  • 6