Monday, April 15, 2024
spot_img

Repair damaged RAR files on Mac OS X

If you’ve ever download large packages of files split up into a batch of RAR files, you may have had the situation where the RAR can’t be expanded due to an error.

If all the files are complete they should have the same number of bytes (except the last file which will likely be smaller than the others), then it is possible some data was corrupted.

RAR files usually contain a repair segment within them. They also contain error checking data (CRC data) in them. This means you can test an RAR file for corruption, and it means you can often repair a RAR file that won’t extract. Of course if any of the files in  batch are incomplete a repair won’t be possible. If the files are exactly 100 MB each, and you have one in the batch that is say 99.999 MB then the file is complete. You may be able to resume the download or you may have to re-download that file. If, however, the files are all complete but one or more have errors, they could likely be repaired.

Here’s how to do it.

Step 1

Follow the instructions in this article to install RAR and UNRAR.

Step 2

Follow the instructions in this article to test the archive for possible damage / corruption. After that, you will have now identified which files in the archive set or batch are damaged.

Step 3

Run Terminal.app (type Terminal into Spotlight search).

With all the RAR and UNRAR commands, any time files will be generated you need to first change the active directory (in Terminal) to the location where you want the output files to go. So the first command (cd) in the following example is for that purpose.

Type in the following into Terminal at the command line:

cd /Users/YourUsername/Downloads/Repaired-Archive-Files/  [or whatever path you wish to use]
rar r    [don't hit enter yet)]

Note, there is a space before and after the free-standing “r“. So it’s rar(space)r(space) – don’t hit enter just yet.

TIP: Also remember you can simply drag folders and files from Finder into Terminal and their full path will magically appear in Terminal. It saves having to type long paths and avoids making errors.

Go to finder and locate the first damaged file you found in the RAR test you performed in Step 2.

Grab the file in Finder and drag it to Terminal. You should now see the full path of the file appear after the rar r part you typed. It will look something like this:

rar r /Users/YourName/Downloads/the-big-download/the-big-download.r03

Hit enter and watch RAR do its work. If the file is repaired you’ll see output along this lines of the following:

Building fixed.the-big-download.r03
Scanning...
Data recovery record found 100%
Sector 183435 (offsets 5991600...5991800) damaged - data recovered
Sector 183436 (offsets 5991800...5991A00) damaged - data recovered
Sector 183437 (offsets 5991A00…5991C00) damaged - data recovered

    [there may be MANY more "Sector… data recovered" lines]

Done

If you see “Done” and all the Sector lines say, “data recovered” at the end, then your file should be complete repaired. Nice, that’ll save you from having to download it again.

Once you’re done with the repair you may need to copy the repaired files into the folder with the rest of the RAR archive files. You will be prompted to replace the existing (damaged) files. Either rename them first, or move them, or simply let them be replaced with the repaired versions.

You’re now ready to do the extraction. You can use one of the many Mac GUI archive tools or you can do it in the command line using the instructions here in this past article.

Recent Articles

spot_img

Related Stories

7 Comments

  1. This is a message to Daniel K. You emailed me about an issue you had with repairing a rar file. Your return email address is bouncing because it is full. So, in the unlikely even you read this blog post again, I will post my reply here.

    – – – –

    Hello Daniel,

    I’ll have to make some guesses.

    Do you have the complete file (set of files) ? Each file will need to be complete. If there is a chunk of any file missing, RAR is not able to replace that.
    What it is able to do is use the CRC data (which is embedded into the RAR files) to correct a certain degree of data corruption.

    I gather your archive set has three files… .00, .01, and .02
    Correct?
    Are you tried to run the repair command on the .02 file.
    And it failed.
    It said “Unexpected end of archive” which suggests to me the file is not complete.

    With my regards,

    Jonathan

Leave a Reply to Nash Ryker Cancel reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox