How to recover a corrupted Illustrator (AI) File

Yesterday I was working on some designs for t-shirts in Adobe Illustrator. Today, when I try to open the file I get a message from Illustrator that says that Illustrator “Can’t open the illustration. The illustration contains an illegal operand.” WTH??

000
So here’s how to fix it. Most people aren’t even aware that there is a feature in Adobe Illustrator called ContentRecovery. By default, this function is turned off. You can turn it on and then recover your file to correct the problem. These are the steps…

Enable content recovery
1. Quit out of Illustrator.
2. Locate your Adobe Illustrator Prefs, make a backup copy and put it somewhere else and then edit the other:
Mac: <user name>/Library/Preferences/Adobe Illustrator CS4 Settings/en_US/Adobe Illustrator Prefs
Windows XP: C:\Documents and Settings\<user name>\Application Data\Adobe\Adobe Illustrator CS4 Settings\en_US\AIPrefs
3. Using a plain text editor that can search, (I used Bean) search for this string: /enableContentRecovery 0
4. Change the 0 (zero) to a 1 and save it. Do not change its filename.

001
Correct the offending command
1. Launch Illustrator.
2. Using File > Open, hold down Command + Option + Shift (Mac), or Ctrl + Alt + Shift (Windows),  and click Open. Do not use Recent files (Mac) or double click the file to open. You want the full Open dialog.
3. Your file will be blank. Close the file without saving or altering.
4. Go back to your directory. You will now have a second file with an underscore at the beginning of the filename. (myfile.ai vs. _myfile.ai).

The underscore file is your recovered file. It will also be larger than your original. Mine was 4.1 megs which shot up to 10.8. When you go into your file later and edit it, it will go back down to the size it was originally.

5. Open your recovered file in a plain text editor and search for something unique in the offending command message. I searched for the word “sugar”. I was able to find the exact line that matched the message. Delete it. Save the file and close.

This is what I deleted:

002a
A word about finding the correct offending command
According to Adobe, there are two things to be aware of…
1. Because postscript is a programming language, functions toggle on and off. So when you delete, your line should start with: %AI8_BeginPluginObject and end with: %AI8_EndPluginObject. The presumed offending command should be between these strings. That means when you delete, block from %AI8_BeginPluginObject and end on %AI8_EndPluginObject. You can see that in the above image where I deleted where it says “BeginEncoding” up to where it says “EndEncoding”.

2. Sometimes, you can have a brush or pattern that can corrupt your file. In this case, you would look for these strings…
(Adobe Calligraphic Brush Tool)
(Adobe Scatter Brush Tool)
(Adobe ArtOnPath Brush Tool)
(Adobe Pattern Brush Tool)

If you find a string that does not match any one of the above, delete it.

Sometimes, you will have to search and delete every instance of the string. In my case, I just happened to find the exact string quoted in the error message. As it turned out, I opened the file and it still loaded the font “Sugar”. The very first thing I did was convert it to outlines to remove it from the document font list altogether.

This is my recovered file…

003