Is it possible to change the way Mathematica saves so that Out[] lines are never included?
I have a .nb file that processes a lot of data, and displays most of it as standard output. These graphs, tables, and intensity plots almost double the size of the file. I'd like to easily save these files in a smaller form and also prevent accidentally sending confidential results to users outside my company or not under an NDA.
That is, of course, without using Cell -> Delete All Output before each save. I can't be expected to remember to do that all the time! :-P
Answer
In Options Inspector you can change the EvaluationOptions for Selected Notebook or for Global Preferences by adding
{"WindowClose" :> FrontEndExecute[FrontEndToken["DeleteGeneratedCells"]]}
to the NotebookEventActions line.
Screenshots for changing the notebook evaluation options in Options Inspector:
A notebook with Input and Output cells and the Evaluation Options page in Option Inspector

After editing the NotebookEventActions line in Options Inspector or evaluating
SetOptions[EvaluationNotebook[], NotebookEventActions -> {"WindowClose" :>
FrontEndExecute[FrontEndToken["DeleteGeneratedCells"]]}];
inside the notebook:

After clicking X on the on the notebooks window frame:

After clicking Yes on the dialog window:

Alternative: you can add
SetOptions[EvaluationNotebook[], NotebookEventActions -> {"WindowClose" :>
FrontEndExecute[FrontEndToken["DeleteGeneratedCells"]]}];
to a notebook's initialization cell.
Comments
Post a Comment