Zipping files



Hi all,

I have come across an error while using zipfile and I can't seem to
find somewhere that explains the problem. My script needs to be able
to take text files from one drive and add them to zip files on another
drive. The following seems to work just fine.

import zipfile

# write test file in working directory directory
folder = "J:/"
filename = "testing.txt"
fullpath = folder+filename
fout = open(fullpath, 'wt')
fout.write(str1)
fout.close()

# Add text file to zip file on same drive
zFolder = "J:/"
zFilename = "testing.zip"
zFullpath = zFolder+zFilename
zout = zipfile.ZipFile(zFullpath, "w")
zout.write(fullpath)
zout.close()
print fullpath, "successfully added to", zFullpath

However, if I change the drive letters to anything other than the
drive from which the Python script is saved (e.g. run script from J:
but zip to C:), I get the following warning:

Traceback (most recent call last):
File "J:/test.py", line 18, in <module>
zout = zipfile.ZipFile(zFullpath, "w")
File "C:\Python25\lib\zipfile.py", line 339, in __init__
self.fp = open(file, modeDict[mode])
IOError: [Errno 13] Permission denied: 'C:/testing.zip'

Can anyopne shed some light on what I am missing here? If it has any
relevance to the permissions part of the error, I am currently using
Windows machines.

Thanks in advance for your time.

Dan

.



Relevant Pages

  • Re: Recursive zipping of Directories in Windows
    ... I am a python novice and I am trying to write a python script (most of ... The script zips all the files fine but when it ... def toZip(directory, zipFile): ... can't handle open files. ...
    (comp.lang.python)
  • simple UnZip
    ... Can someone help me with this script, ... unzips one file from a zipfile, not all files in a zipfile. ... for fzip in zips: ... print fzip," is a zip" ...
    (comp.lang.python)
  • Recursive zipping of Directories in Windows
    ... I am a python novice and I am trying to write a python script (most of ... The script zips all the files fine but when it ... def toZip(directory, zipFile): ... the directory permissions it is set back to "Read Only" ...
    (comp.lang.python)
  • Re: Zipping files
    ... I have come across an error while using zipfile and I can't seem to ... My script needs to be able ... zout = zipfile.ZipFile ... on XP don't have that permission, ...
    (comp.lang.python)
  • Re: Zip a file programatically
    ... OK, Miyahn, your "unreliable" script works on WinXP SP2 if any ... > ZipFile = FS.BuildPath ... > On Error GoTo 0 ... > Sub SelectItem ...
    (microsoft.public.scripting.vbscript)