How can I clean up a notebook?

Update

I have incorporated Kuba's improvement into the code.

Here is how I would do it.

  1. In a working notebook (not the target notebook) put the following code.

    With[{nb = target},
      SetOptions[nb, ShowCellBracket -> False];
      SetOptions[#, CellOpen -> False] & /@ Cells[nb, CellStyle -> "Input"];]
    
    With[{nb = taget},
      SetOptions[nb, ShowCellBracket -> True];
      SetOptions[#, CellOpen -> True] & /@ Cells[nb, CellStyle -> "Input"];]
    

    The first code cell will do the clean-up. The second lets you undo it if that becomes necessary.

  2. Now in the target notebook evaluate

    EvaluationNotebook[]
    

    This will return a notebook object which will look something like

    $\qquad$nbobj

  3. Cut the notebook object from the target notebook.

  4. Select the first token target in the working notebook and paste the notebook object over it.

  5. Do the same thing for the other target token.

  6. Delete the EvaluationNotebook[] code from the target notebook.

  7. Evaluate the first of the two code cells.

After pasting the notebook object into working notebook, that notebook should look like this:

code


Another possibility is to modify the notebooks style sheet by defining a new "Screen Environment" that hides cell brackets and closes input cells:

SetOptions[
    EvaluationNotebook[],
    StyleDefinitions -> Notebook[{
        Cell[StyleData[StyleDefinitions->"Default.nb"]],
        Cell[StyleData[All, "Working"], MenuCommandKey->"D"],
        Cell[StyleData[All, "Clean"],
            MenuCommandKey->"C",
            ShowCellBracket->False,
            MenuSortingValue -> 10000
        ],
        Cell[StyleData["Input", "Clean"],
            CellOpen->False]
        },
        StyleDefinitions->"PrivateStylesheetFormatting.nb"
    ]
]

The "Clean" environment hides cell brackets and closes input cells. I also gave it a keyboard short cut, so that using Command+c switches to the "Clean" environment, and Command+d switches back to the working environment. Here is an animation:

enter image description here

Note that I used the keyboard shortcuts to switch at the end of the animation.