Zip problems
Ford Prefect
beeblebrox at operamail.com
Fri Jun 22 01:56:14 EDT 2001
I have problems using zipfile. Script below makes a zip file but when
I try to extract files from the zip with WinAce or Windows Commander I
get CRC error. At first I thought the problem was in Windows Commander
and contacted the author (I also sent him the zip file). This is (part
of) his reply:
"This ZIP file is indeed faulty. In the header it has a bit set that
the CRC
is stored after the packed data, with header PK#7#8. But this header
is
missing and there is no CRC following the data. The CRC field of the
local header is also empty."
WinAce also reports CRC error.
Can someone tell me what can I do to make zipfile work correctly. Or
is it something in the script? I am using ActiveState ActivePython
2.10 Build 210.
import os
import os.path
import time
import zipfile
import glob
srcpath = 'c:\\'
archive = 'c:\\'
archive += 'backup'
archive += time.strftime('%Y%m%d', time.localtime(time.time())) +
'.zip'
zipf = zipfile.ZipFile(archive, "w")
print 'creating:', archive
files = glob.glob(srcpath + '*.bat')
for file in files:
if os.path.isfile(file):
print 'adding:', file
zipf.write(file, os.path.basename(file), zipfile.ZIP_DEFLATED)
zipf.close()
print archive, 'created'
More information about the Python-list
mailing list