89

I've a corrupt zip file. I've tried to repair it with

zip -F file.zip

and

zip -FF file.zip

but was not successful. Is there another terminal tool under Linux for repairing?

cupakob
  • 1,143
  • Maybe the file is FUBR? – LiraNuna Aug 30 '09 at 01:30
  • Tfw you thought you made a backup and nuked an eMac hard drive for untold shenanigans, but you never copied that file to your main machine and the filesystem on the USB drive gets corrupted. Take time to ensure your backups are good folks! Thankfully I only lost an old iTunes library. – qwerty keyboard Feb 09 '24 at 03:49

7 Answers7

143

try this

zip -FF Corrupted.zip --out New.zip

This will scan the corrupted zip archive and make a new one eliminating the errors.

As a result you will get a new zip file. Then simply run this command.

unzip New.zip

Hope this helps.

Desi
  • 1,431
  • 11
    Thanks for this answer. Doing it this way didn't really give me a working zip-file, running the command again over the new zip file did do the trick. It was a desperate move, didn't expect it to work. – Rein Nov 06 '16 at 12:28
  • 2
    Worked great on Ubuntu 20.04 LTS~ Context: my zip was created on Windows 10, uploaded to OneDrive, and downloaded in Ubuntu. Zip worked on Windows but not on Ubuntu but the answer fixed the issue. – dance2die Aug 01 '20 at 18:56
  • Saved the day, Ubuntu 20.04. Thanks! – xd1936 Oct 12 '20 at 20:16
  • @Desi: AWESOME (MacOS 11.6.1) many thanks! – ecjb Aug 22 '22 at 14:59
32

Just referenced this question in my answer to a similar one - Linux Mint 12 - how to open a .zip file in terminal

It is worth adding here what the zip manual currently says about the difference between -F and -FF:

The single -F is more reliable if the archive is not too much damaged, so try this option first.

So the first attempt would be:

zip -F broken.zip --out fixed.zip
unzip fixed.zip

And if that doesn't work:

zip -FF broken.zip --out fixed.zip
unzip fixed.zip
Graeme
  • 875
12

I recently encountered a .zip file that neither zip -F file.zip nor zip -FF file.zip could fix. However,

7z x file.zip

was able to extract all the files. Hence, trying out p7zip could be a good idea. If needed, you can then pack the extracted files into a new archive.

6

DiskInternals ZIP Repair works perfectly under Wine it's saved me in the past.

  • 3
    You can also just extract the actual executable from the installer using 7-Zip. Works like a charm. – Goyuix Sep 25 '10 at 15:46
5

I'm not aware of a program that will do a better job repairing the archive though.

You might try

unzip -vt file.zip

just to see if maybe you can extract some of the files safely, or figure out which files in the archive are corrupt.

Guy
  • 151
  • 2
    thanks for the hint, but i get the same result as with "zip -F" :( –  Aug 13 '09 at 21:33
0

Due to permission errors, a ZIP process of mine crashed consistently before moving the temporary ZIP file into the final ZIP file.

The result was a folder full of temporary files named zi<random>, e.g. zi0Be571a.

zip -F did not work, nor did zip -FF, 7z x, ziprecover. The error was that the file did not contain a central directory.

On Windows, WinRAR gave an error but did display the (partial) file contents.

DiskInternals ZipRecover was able to scan the temporary file and reconstruct the central directory, yielding a perfectly recovered Zip file.

LSerni
  • 8,455
0

The man page of zip explains:

The -FF option may create an inconsistent archive. Depending on what is damaged, you can then use the -F option to fix that archive.

So, you run:

zip -FF damaged.zip --out fix1.zip
zip -F fix1.zip --out fix2.zip
unzip fix2.zip

This approach worked for my damaged zip file.

Aidin
  • 141