Restoring a Notebook
This section assumes that you have already loaded the AuthorTools package and set the variables nb1 and nb2 to represent the notebooks you wish to process. (See Using Functions for more information.)
NotebookRestore takes a notebook containing one or more syntax errors and creates a new notebook containing all the cells that did not have a syntax error. For example, suppose nb1 represents a notebook file that has been corrupted by removing one quote from a cell style name. If you try to open this file, the front end will report a syntax error and suggest you cancel the open operation.
Using NotebookRestore, you can at least access those cells in the notebook that are not corrupted. NotebookRestore will open a new notebook window containing all the good cells from the given notebook file and insert an indicator at each place where notebook data has been deleted.
Instead of deleting the corrupt data, you can display it verbatim within the indicator by setting the option DeleteCorruptCells False.
All the corrupt cell indicators have the cell tag "Corrupt", so you can easily highlight them by choosing Corrupt from the list of cell tags displayed under the Find Cell Tags menu. Alternatively, you can walk through each indicator one by one using the NextCorruptCell function.
If your notebook contains large graphics cells or large blocks of typesetting, it may take a long time for Mathematica to read in the expression and try to determine if it contains any syntax errors. For that reason, there are options that allow you to skip over graphics and/or typeset cells without processing them.
SalvageCells is a non-interactive way to extract the list cells from a corrupt notebook file. This function is intended for users who want to manipulate the cell listing directly, as part of a program. SalvageCells takes the same options, and returns the same information, as NotebookRestore.
This salvages all the cells from a notebook file.
This gives the total number of cells.
This gives the total number of blocks removed from the notebook.
You can view just the bad data in a separate notebook.