Mac OS X: Recovering a corrupted zip file
June 25, 2010 10:27 AM   Subscribe

I've got a ~350mb zip archive that I created a couple of years ago. It contains files that are now fairly important to my portfolio. And I can't get them out. Please hope me.

Opening the file in the Finder leads to a progress bar that crunches away promisingly for several seconds, only to fail with the message "Unable to unarchive FILE.zip into [DIRECTORY] (Error 1 - Operation not permitted.)"

Dropping into the terminal and using unzip instead immediately tells me "End-of-central-directory signature not found" and "cannot find zipfile directory".

Maddeningly, I can grep the zipfile for "pdf" and SEE the pdf filenames in thereā€”at least SOME of the data is there. And I mean, the thing's 350 megs. Something must be in there. I have no idea how to get to it, though. Googling the error messages has not been helpful.

There's nothing confidential in the file, so I'm happy to put it online for anybody to take a crack at, if that would be helpful.
posted by pts to Computers & Internet (8 answers total) 4 users marked this as a favorite
 
See if you have the plain 'zip' program. It has a "-F fix zipfile (-FF try harder)" option thay may help.
posted by zengargoyle at 10:39 AM on June 25, 2010 [2 favorites]


Can you confirm it's a real zip?
Run the "file" command on the file in the terminal and see what it says. It could be something weird like a tar file with a .zip extension.
posted by bottlebrushtree at 10:54 AM on June 25, 2010


Holy shit, a couple of passes of zip -FF did the trick.

It looks like only about half of what was supposed to be there was actually there, so I infer what happened was the file upload got interrupted and I only got part of it. But hell, half of my portfolio is a lot better than none of my portfolio.

zengargoyle, I'll raise a glass in your honor tonight.
posted by pts at 11:01 AM on June 25, 2010


Just FYI, the zip file structure puts a "central directory" at the end of the file. This is where unzip programs first look to begin decompression, and if the file was truncated that is why they are failing. The -F option tries to reconstruct that central directory by looking at the local file headers of each entry. Note that the filename is stored in both locations, so that's why you could still see filenames even with a missing central directory.

This is also why you can concatenate a jpeg file with a zip file and have something the displays/acts like as an image but can also be unzipped, allowing you to "hide" files in an image. The jpeg file format has its header at the beginning of the file, so image decoding algorithms look there, and the zip file format has its header at the end of the file so unzipping programs look there first.
posted by Rhomboid at 3:05 PM on June 25, 2010 [3 favorites]


As an aside, I've run into enough problems with archive create / extract in OS X's Finder that I just don't trust it to write or read large-ish files.

It may not work since you've already tampered with the file using zip -FF, but I've had maximum success with the OS X command

ditto -x -k source.zip Destination_Dir

The last couple of times I had problems, everything else I tried chewed on the file for 10 minutes before giving up and recovering nothing. ditto recovered 80% of the contents.
posted by Pinback at 4:35 PM on June 25, 2010


I have a very similar situation with a file I have recovered from a friends thumb drive. the drive was unreadable on my Mac, but FileSalvage recovered a file named "1.gz" at just over a gig.

If I double click on it I get Error 2 No Such File or Directory.

I am not sure how to apply either the "ditto -x -k source.zip Destination_Dir" or the "zip -FF" commands to this file mentioned earlier in this post. If anyone can guide me through it I would be much appreciated.

(needs basic Terminal help)

Henry
posted by silsurf at 5:09 PM on June 27, 2010


gzip (.gz) and info-zip (.zip) are completely different things, and neither of those commands are appropriate for gzip files. Specifically, the .gz file format is not an archive format (i.e. bundling multiple files) but only a means of compression -- each .gz file contains only one file, so there is no directory to reconstruct as with .zip files. That's why gzip is usually combined with tar.

If you want to test the integrity of the .gz file, try gzip -t. If you want to try extracting it, use gzip -d aka gunzip. You might also want to verify that it's actually a gzip file, which the 'file' command should tell you.
posted by Rhomboid at 5:35 PM on June 27, 2010


thanks, but can you give slightly newbier instructions? I use terminal once in a while, but not without a lot of hand holding.

Where should I place to file in question (say desktop) and how do I instruct terminal to perform said actions on that file?

Thanks!

Henry
posted by silsurf at 7:35 PM on June 27, 2010


« Older Master degree or NOT   |   Help me use my old iphone for mad science Newer »
This thread is closed to new comments.