[Tutor] copy zip file from source folder to destination and unzip all files within destination

MARCUS NG markersng at gmail.com
Fri Nov 20 07:54:48 CET 2009


Hey all,
I have been searching online for ways to copy a zip file to a destination
and extract the zip file with python.
Currently nothing works due to my limited understanding.
I am wondering if my syntax is wrong or am I missing anything?
the code is as such. also if there is a better code, I am definitely open to
it. If it is good, can you also explain steps?
###########

import shutil, zipfile
shutil.copyfile('C:\Users\blueman\Desktop\myTest1.0.zip',
'C:\Users\blueman\Desktop\allFiles')

zipfilepath='C:\Users\blueman\Desktop\allFiles\myTest1.0.zip'
extractiondir='C:\Users\blueman\Desktop\allFiles\test'

def extract(zipfilepath, extractiondir):
    zip = zipfile(zipfilepath)
    zip.extractall(path=extractiondir)
    print 'it works'

extract()

###########
thank you so much for your time and help in advance!!!


,
Marcus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091120/ce7064c3/attachment.htm>


More information about the Tutor mailing list