vote up 3 vote down star

Hi all,

I need to make a zip file available to all my windows users visitors, so I naively produced a zip file with the unix zip command (let's call it madeinlinux.zip).

It opens successfully with WinRar or Winzip, but those of my users who are using the standard windows zip file handling experience failure when trying to unzip it. (Win XP)

I compressed the same data using windows built-in zip mecanism, and from a linux point of view, I cannot see any difference in the file type:

$ file madeinlinux.zip :  Zip archive data, at least v2.0 to extract
$ file madeinwindows.zip : Zip archive data, at least v2.0 to extract

They're must be something specific to a windows compatible zip file.

Does anyone knows what?

Cheers !!!

J.

flag
1  
Could you produce one of these ZIP files (with dummy content) and put it on a server for us to download and inspect? – Bernhard Hofmann Jul 10 at 10:45
This sounds like a case for superuser.com, if it exists yet. – unwind Jul 10 at 10:45
Sure bernhard, here's the culprit: careerjet.co.uk/devel/Services_Careerjet.zip – jeje Jul 10 at 10:51
The only windows machine I had to test was a Windows 7 one, and that had no problems opening and extracting the file using explorer. – Andre Miller Jul 10 at 10:55
hail windows 7 ! – jeje Jul 10 at 11:13
show 1 more comment

migrated from stackoverflow.com

6 Answers

vote up 1 vote down

Only thing that looks relevant is this

-k - Attempt  to  convert  the  names  and paths to conform to MSDOS, store only the MSDOS attribute (just the user write attribute from UNIX), and mark the entry as made under
MSDOS (even though it was not); for compatibility with PKUNZIP under MSDOS which cannot handle certain names such as those with two dots.

but do read "man zip" on your system before going anywhere else...

link|flag
Hi. Thx for the suggestion, but this -k option takes me back in time a bit too much. It transforms all file name in a 8 character/no case version :( – jeje Jul 10 at 11:41
Yeah, I remember those days. But did it help the file to read by the built-in Zip program on Windows? – Daniel Rosenstark Jul 10 at 13:43
Don't know. This file name issue stopped me trying – jeje Jul 10 at 15:55
My guess is that it's the compression, as MSalters says... – Daniel Rosenstark Jul 10 at 19:20
vote up 1 vote down

zip -Z sets the compression option. -Z store is the most trivial one, as it doesn't compress at all. This is useful when you're using zip as an alternative for tar, or when troubleshooting. In this case you should try to see if an uncompressed archive is usable from Windows. If that is usable, you know that you'll have to pick a non-default compression option.

link|flag
awesome, I'd guess it's the compression algorithm that is causing trouble too... – Daniel Rosenstark Jul 10 at 13:44
vote up 0 vote down

Here is a python script that I am using to zip some files. It has been tested on ubuntu and Vista. A zip generated on Ubuntu opens with the Vista zipper.

I think that I had a similar issue in the past and it was because the zip format was not ZIP_DEFLATED. I am not sure. I will check that.

I hope it helps

import zipfile
import glob, os, sys

class ZipArchive:

    def zip_it(self, dirName, files):
        dirNamePrefix = dirName+"/*"
        for filename in glob.glob(dirNamePrefix):
            if os.path.isfile(filename) and (not self.exclude_svn or (filename.find(".svn\\")==-1)):
                print filename
                name = filename[len(self.folder)+1:]
                self.archive.write(filename, name, zipfile.ZIP_DEFLATED)

    def run(self, folder, name, exclude_svn):
        self.exclude_svn = exclude_svn
        self.folder = folder
        self.archive = zipfile.ZipFile(name+".zip", "w")
        os.path.walk(self.folder, ZipArchive.zip_it, self)
        self.archive.close()

if __name__ == "__main__":
    if (len(sys.argv)==1):
        print "usage zipit folder [name] [svn:yes|no]"
    else:
        name = sys.argv[1]
        exclude_svn = False

        if (len(sys.argv)>2): name = sys.argv[2]
        if (len(sys.argv)>3): exclude_svn = (sys.argv[3]=="no")

        arch = ZipArchive()
        arch.run(sys.argv[1], name, exclude_svn)
        print "done"

link|flag
the question is, can it be unzipped using Windows zip mechanism? – Anonymous Jul 10 at 12:07
yes. i've opened it with the Vista zip tool. I hope it works for you too – luc Jul 10 at 12:25
vote up 0 vote down

7zip is an open source compression tool that works on Linux, FreeBSD, Mac OS X, BeOS, DOS, Amiga and Windows.

I would highly recommend it based on the windows version.

It supports

packing / unpacking: 7z, ZIP, GZIP, BZIP2 and TAR

Unpacking only: ARJ, CAB, CHM, CPIO, DEB, DMG, HFS, ISO, LZH, LZMA, MSI, NSIS, RAR, RPM, UDF, WIM, XAR and Z.

link|flag
vote up -1 vote down

@OP, did you try gzip instead?

link|flag
1  
you should not answer with a question. if you need more info, make a comment to his question. – George IV Jul 10 at 11:19
vote up -1 vote down

@ghostdog74: gzip does definitely NOT open on windows, especially as it compresses only a single file, and is usually combined with tar when doing multiple files.

link|flag
You should add this is a comment on his answer instead of creating a new answer. That's what the comment system is for. – Andre Miller Jul 10 at 11:14
you should say it properly. gzip does open on windows BUT not by Windows own zip mechanism. – Anonymous Jul 10 at 11:23
Sorry - I would have commented, but didn't have enough reputation. (now I have even less :) – gromgull Jul 10 at 11:49

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.