There is of course function


enter image description here

But, unfortunatelly it hasn't got useful options in this context.

My question is how to pick Notebooks excluding:

  • Help,
  • Palettes,
  • Packages,
  • Messages,
  • Text notebooks.

Parsing Notebook/CellInformation functions, I've found Patterns, e.g.:

ClearAttributes[Developer`CellInformation, ReadProtected]
DownValues @ Developer`CellInformation
[...]  (_FrontEnd`SelectedNotebook | _FrontEnd`InputNotebook | 
 _FrontEnd`ButtonNotebook | _FrontEnd`EvaluationNotebook | 
 _FrontEnd`MessagesNotebook | _FrontEnd`HelpBrowserNotebook | 
 _FrontEnd`ClipboardNotebook) | (_CellObject | _FrontEnd`CellObject) [...]

Those patterns seem to be what I need but I've not managed to use them. Any tips or another solution?


4 Answers 4


I think the information given by AbsoluteOptions will be enough to distinguish one type of Notebook from another.

To investigate the differences among the option values of different Notebooks, we first prepare all six types of Notebooks:

nblist = Complement[Notebooks[], {EvaluationNotebook[]}]

test notebooks

Then we extract all of their AbsoluteOptions, and delete those which are the same among different types of Notebooks.

Then we count the (rescaled) commonness of the option values. e.g. Option CellLabelAutoDelete has value True for Message, Package, Text, Palette and ordinary Notebook, but False for Help windows, so the commonness of CellLabelAutoDelete for Message, Package, Text, Palette, ordinary Notebook and Help will be MapAt[Rescale, Tally[{True, True, True, True, True, False}]\[Transpose], 2]\[Transpose], which is {{True, 1}, {False, 0}}. i.e. the more common the value of an option is, the more the commonness of the option approaches 1. By counting the commonness, we can identify the most unique options a Notebook type has.

nboptSet = AbsoluteOptions /@ nblist;
nbopts = nboptSet // Flatten // #[[All, 1]] & // Union;
optdataRules = DeleteCases[
      {#, MapAt[Rescale, Tally[# /. nboptSet]\[Transpose], 2]\[Transpose]} & /@ nbopts,
      {_, {{__}}}, 1]\[Transpose] //
    MapAt[Map[Rule @@ # &, #, {2}] &, #, 2] & //
   SortBy[#, First] &;

At last we plot out the chart:

MapThread[#1 /. #2 &, {optdataRules[[1]] /. #, optdataRules[[2]]}] & /@ nboptSet //
    Map[Item["", Background -> GrayLevel[# + .8]] &, #, {2}] & //
   Prepend[#, optdataRules[[1]]] & //
  Prepend[#\[Transpose], {"", "Msg", "Pkg", "Txt", "Plt", "ONb", "Hlp"}] & //
 Grid[#, Frame -> All, Alignment -> Left, FrameStyle -> GrayLevel[.7]] &

commonness statistics

Now it's clear to see that CellInsertionPointCell is (one of) the perfect "fingerprint" of ordinary Notebook-s. So the filter function is simple:

   (CellInsertionPointCell /. AbsoluteOptions[#, CellInsertionPointCell]) =!= None & /@ #
   ] & @ Notebooks[]

ordnb filter result

  • $\begingroup$ You've done what I was too lazy (ashamed) to do. Thank you :) $\endgroup$
    – Kuba
    Mar 28, 2014 at 20:31
  • $\begingroup$ @Kuba You're welcome:) I think I spent too much time on trying different color schemes for the Grid O_o $\endgroup$
    – Silvia
    Mar 28, 2014 at 20:33
  • 1
    $\begingroup$ It is standard for me that I'm wasting 80% time for secondary quests while playing with mma :) $\endgroup$
    – Kuba
    Mar 28, 2014 at 20:39
  • $\begingroup$ @Kuba I'm hoping someone will give a machine learning and classification answer :D $\endgroup$
    – Silvia
    Mar 28, 2014 at 20:45
  • $\begingroup$ Oh my, there will be so many things to test. :) $\endgroup$
    – Kuba
    Mar 28, 2014 at 20:49

I don't know any neat answer but here's one that works for me at the moment.

  • How we can detect Help, Text, Package type notebooks:

    "DocumentType" /. NotebookInformation /@ Notebooks[]
    {"Notebook", "Notebook", "Notebook", "Help", "Package", "Text", "Notebook",
    "Notebook", "Notebook", "Notebook"}
  • Message is the only one with no external "StyleDefinitions":

    {#, "StyleDefinitions" /. NotebookInformation[#]} & /@ Notebooks[]

    enter image description here

    In fact this method could help further, but people often change things in styles so I do not trust it. Let's:

  • ... find Palettes using FrontEndTokens (list of tokens), with a support of answer on MathGroup by John Fultz:


So at the end I'm using:

 Complement[#, FE`Evaluate[FEPrivate`GetPopupList["MenuListPaletteWindows"]][[;;,1]]] &,
 DeleteCases[#, {_, {"Text" | "Help" | "Package", _}} | {_, {_, None}}, 1][[;; , 1]] &,
 Map[{#, {"DocumentType", "StyleDefinitions"} /. NotebookInformation[#]} &, #] &

But it is soo ugly :(

  • $\begingroup$ +1. btw instead of NotebookInformation, it might be worth trying AbsoluteOptions on every nb, I believe the information will be more than enough to distinguish one from another. $\endgroup$
    – Silvia
    Mar 28, 2014 at 16:41
  • $\begingroup$ @Silvia You are probably right, but there is to much to scan :) so I've taken easier but longer road $\endgroup$
    – Kuba
    Mar 28, 2014 at 16:51
  • $\begingroup$ The scan can be done automatically. (well at least they appear to be if we ignore all the coding time!) Please see my answer for detail :) $\endgroup$
    – Silvia
    Mar 28, 2014 at 20:26

Palettes have a specific window frame, so:

DeleteCases[Notebooks[], x_ /; MemberQ[Options[x], WindowFrame -> "Palette"]]

The Help seems to have a specific docked cell, so:

 x_ /; MemberQ[Options[x], DockedCells -> 
 FEPrivate`FrontEndResource["FEExpressions", "HelpViewerToolbar"]]]

So you can combine these two:

 x_ /; MemberQ[Options[x], 
   HoldPattern[_ -> 
       "HelpViewerToolbar"] | "Palette"]]]

...and continuing along like this you should hopefully be able to find notebook options that are specific only to the sort of notebooks you want to exclude, and once identified use that as a way of excluding the notebook.

Names["FrontEnd`*" ~~ "`" ... ~~ "Notebook"] // Column



Of these, the following seem useful for filtering

useful = {(*FrontEnd`ClipboardNotebook,*)
  FrontEnd`DebuggerStackNotebook, FrontEnd`HelpBrowserNotebook, 

I have commented out ClipboardNotebook, as I do not know how it works. But probably it is useful. I thought HelpBrowserNotebook was not useful at first, but it is just something different than I expected. To generate a HelpBrowserNotebook, evaluate


Then, a first filter, that you could combine with other answers, would be

 Cases[FrontEndExecute[#[]] & /@ useful, _NotebookObject]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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