Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

In developing a notebook, I often find I have created a very boated file that takes a long time to save. I would like to slim it down. It is usually the result of graphics and images, but they may be hidden deep in the hierarchy of the notebook. Finding the wasted space is a pain. A very useful tool would be something that graphically indicated (perhaps in the cell marker) the number of bytes (or similar) that are within a cell. Anyone know of such a thing, or have a pointer on how to create?

share|improve this question
2  
Nice idea, seems totally doable –  Rojo Jul 25 '12 at 2:05
    
You could automate conversion of all images to bitmap. –  Mike Honeychurch Jul 25 '12 at 2:43
    
I asked WRI if it's possible to toggle the front end to display graphic output and the output of ancillary (exploratory) code in a separate notebook on a per-cell basis, but the reply I got didn't sound promising. –  alancalvitti Jul 25 '12 at 3:05
4  
Top Menu: Cell >> Delete All output - saves a lot of space for notebooks with a lot of graphics. –  Vitaliy Kaurov Jul 25 '12 at 3:20
    
In addition to @VitaliyKaurov: programmatically delete certain cells (here Output): NotebookFind[ SelectedNotebook[], "Output", All, CellStyle]; NotebookDelete[ SelectedNotebook[]] –  Yves Klett Jul 25 '12 at 6:43
show 5 more comments

1 Answer

Maybe, displaying the bytecount of every output expression in tooltips or status area:

$Post = Tooltip[#, ByteCount[#]] &

or

$Post = StatusArea[#, ByteCount[#]] &

To delete all generated cells in the notebook, evaluate

FrontEndExecute[FrontEndToken["DeleteGeneratedCells"]]

or

FrontEndTokenExecute["DeleteGeneratedCells"]

To delete all generated cells upon closing a notebook, you can use

SetOptions[EvaluationNotebook[], NotebookEventActions -> {"WindowClose" :>   FrontEndExecute[FrontEndToken["DeleteGeneratedCells"]]}]; 

inside the notebook.

Or, you can select Selected Notebook or Global Preferences in the Options Inspector and add

{"WindowClose" :>  FrontEndExecute[FrontEndToken["DeleteGeneratedCells"]]} 

to the NotebookEventActions line.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.