Re: Batch evaluation of multiple notebooks?
- To: mathgroup at smc.vnet.net
- Subject: [mg69570] Re: Batch evaluation of multiple notebooks?
- From: Rolf.Mertig at gmail.com
- Date: Fri, 15 Sep 2006 06:47:16 -0400 (EDT)
- References: <edjhj7$m01$1@smc.vnet.net><edom2j$huc$1@smc.vnet.net>
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 NB2PDF["C:\\nbfiles\\samplenotebook.nb"] 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: http://www.gluonvision.com/downloads/NB2PDF.m I have not tested it extensively, so feel free to play around. For the PDFcreation extra software has to be installed: https://sourceforge.net/projects/pdfcreator Regards, Rolf 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