Fix Corrupted Zip Files in Linux [Quick Tip]

by Keith Dsouza | Translate | Print
Thursday, 17th Jul 2008 | Share


Share Fix Corrupted Zip Files in Linux [Quick Tip] on Twitter Share Fix Corrupted Zip Files in Linux [Quick Tip] on Facebook Save Fix Corrupted Zip Files in Linux [Quick Tip] To Delicious Favorites Stumble Fix Corrupted Zip Files in Linux [Quick Tip] Share Fix Corrupted Zip Files in Linux [Quick Tip] on Digg Get Instant Updates as RSS Feeds from Techie Buzz


It’s been a long time since I have talked about Linux, so here is something to get started again. This post talks about a common problem, “Corrupted Zip File” which people face while downloading zip files from the Internet.

Not all the zip files can be recovered but using a few simple commands, you can try and recover the content without having to re-download the file again.

You can easily repair “repairable” zip files downloaded on Linux by issuing the following command;

zip –F “filename.zip”

Issuing this command will tell the zip command to try to fix the zipfile if necessary. You can also issue the following command to make it the zip command work more harder on fixing the zip file.

zip –FF “filename.zip”

I initially used this command as a patch to a shell script that read contents from a zip file, that was uploaded by a wizard, the patch was put in for zip files which were corrupted when uploaded over slower Internet connections.

Here is a part of the shell script for the geeks and power users reading Techie Buzz.

   1: unzip -tqqq $x >> /dev/null;
   2:     if [ $? -ne 0 ]; then
   3:       #Run Recovery mode first - do not remove this code - kd
   4:       zip -FF $x;
   5:       unzip -tqqq $x >> /dev/null;
   6:       if [ $? -ne 0 ]; then
   7:         echo "Could not unzip $x. Renaming it to BADZIP-$x";
   8:         mv $x BADZIP-$x;
   9:         continue;
  10:       fi
  11:     fi

Enjoy and look forward to more Linux Tips.



Share

2 Responses so far | Share Your Opinions!

  1. abhishek
    July 17th, 2008 at 10:33 am #

    gud tip, keep them coming more.

    Reply to this comment

  2. Raj
    July 17th, 2008 at 11:24 am #

    Nice Tip.
    Thanks

    Stumbled

    Reply to this comment

Leave a Comment

Note: We discourage users from using keywords in their names while posting comments, most of them get caught by spam, also it really would be more fruitful in knowing people who comment by their real name, rather than by using a name no one relates to. In future we reserve the right to delete comments from users using a name other than their own.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>