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.

I have a Mathematica 6 course that I am using in Mathematica 9; there is no updated version. Every time I open a notebook I have to go to the Evaluation menu and click on "Evaluate Notebook". Is there a way for me to set it so that it automatically evaluates a notebook upon my opening it? I keep getting answers on shortcuts I can use once the notebook is open or pressing shift-enter on a cell but that's not an answer; I would like not to do anything at all other than open the notebook and have every cell evaluated already since the tutorial course is long and contains a ton of notebooks.

share|improve this question
add comment

2 Answers

With the option inspector (shiftctrlO) you can set the value of the option InitializationCellEvaluation to True (make sure that you select "Global Preferences"). Setting InitializationCellWarning to False suppresses the dialog you would normally get. Please note that this may entail a potential security issue.

enter image description here

You can do it programmatically as well:

SetOptions[$FrontEndSession, 
  InitializationCellEvaluation -> True, 
  InitializationCellWarning -> False
]

I used$FrontEndSession here, so that the effect lasts for the session only (safer), but if you want to make this more permanent you could change that to $FrontEnd.


UPDATE

Assuming that you have all the notebooks in one directory dir, you could open and evaluate them all at once by using:

NotebookEvaluate /@ NotebookOpen /@ FileNames["*.nb", dir]
share|improve this answer
    
I had already tried this and it didn't work :( –  Anthony Apr 10 '13 at 20:03
    
@anthony I was assuming your notebooks would have initialization cells, but apparently they don't. –  Sjoerd C. de Vries Apr 10 '13 at 20:23
    
@Anthony Perhaps the update meets your requirements? –  Sjoerd C. de Vries Apr 10 '13 at 20:40
    
Unfortunately this would open hundreds of notebooks; I only go through certain notebooks as needed. –  Anthony Apr 12 '13 at 18:00
    
@Anthony I suggest that you do a ctrl-a shift-return upon opening a notebook. Those two key presses should be easy to perform. Or is that too much effort for you? –  Sjoerd C. de Vries Apr 12 '13 at 18:35
show 1 more comment

One thing you could do would be to make a master notebook with lots of

NotebookEvaluate[notebook] 

commands. Then execute all the ones you'll need at the start in one group. Then when you open them, they'll already be evaluated. You could do this programmatically by reading in and evaluating all the notebooks in a directory.

share|improve this answer
    
But this option would require a lot more work than simply evaluating a notebook myself. –  Anthony Apr 10 '13 at 20:04
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.