MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Batch evaluation of multiple notebooks?

  • To: mathgroup at
  • Subject: [mg69570] Re: Batch evaluation of multiple notebooks?
  • From: Rolf.Mertig at
  • Date: Fri, 15 Sep 2006 06:47:16 -0400 (EDT)
  • References: <edjhj7$m01$><edom2j$huc$>

The real fun is to run it in the background under Windows (i.e., from a
DOS shell, e.g.
math < NB2PDF.m > NB2PDF.out
where one execution line
is added after the package.
This produces not just samplenotebook_Evaluate.nb, but
also a PDF file of the evaluted  notebook.
I once wrote a little package to do this (Windows only for the moment,
but should be
easily adaptable for other OS's; I do it if wished).
Since it is a little longish I put it here:

I have not tested it extensively, so feel free to play around.

For the PDFcreation extra software has to be installed:



Blackadder schrieb:

> Thanks a lot, worked like a charm! The fine thing about this method is
> that control over the evaluation and closing of each notebook
> completely remains within the main loop.
> I came up with another idea that will cause the notebooks to be
> evaluated in sequential order. The main notebook contains a list of
> files to process, say "fileList" and an integer index pointer to this
> list, called "currFileIdx" . Now you define a function "excuteNotebook"
> like this:
> executeNotebook[fname_String] := Module[{},
>    If[currFileIdx<Length[fileList],
>       openNotebook = NotebookOpen[fname, Visible -> True];
>       SelectionMove[openNotebook, After, Notebook];
>       NotebookWrite[openNotebook,
> "currFileIdx++;executeNotebook[fileList[[currFileIdx]]];"];
>       SelectionMove[openNotebook, All, Notebook];
>       SelectionEvaluate[openNotebook];
>    ];
> ];
> This function appends the command to evaluate the next notebook to the
> one that is currently active. You thus build up a chain of evaluations
> where each notebook calls the next one to be evaluated. This works ok,
> too, but Roland's version is way more elegant and presumably safer.
> Best wishes, Malte
> --
> Roland Franzius schrieb:
> > The good old semaphore technics from mainframe times:
> >
> > Let each Notebook create a "I am finished (nr xx).txt" file and hold the
> > main loop idling before executing the next notebook until the expected
> > file does show up to exist.
> > 
> > -- 
> > 
> > Roland Franzius

  • Prev by Date: Re: How to tell Mathematica to stop conditional testing in an If statment if one condition is niether True or False? McCarthy evaluation rules? 'and then' test?
  • Next by Date: Re: partials of Sum[x[i]^2, {i,1,n}] (e.g.)
  • Previous by thread: Re: Batch evaluation of multiple notebooks?
  • Next by thread: Using FullSimplify to check hand algebra