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.

Step 1

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.

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:

Shell

1

rarr/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:

Shell

1

2

3

4

5

6

7

8

9

10

Building fixed.the-big-download.r03

Scanning...

Data recovery record found100%

Sector183435(offsets5991600...5991800)damaged-data recovered

Sector183436(offsets5991800...5991A00)damaged-data recovered

Sector183437(offsets5991A00…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.

Related

4 Comments

Jonathan
on June 24, 2013 at 11:46 pm

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.