4
$\begingroup$

I would like to be able to delete any open notebook with some specific text string in its name. Notebooks[] returns a list of open notebook objects, but to get the names, I am using a kluge involving

ToString[NotebookGet[#]]&/@Notebooks[]

followed by using StringPosition[#,"WindowsTitle"] and then StringTake[] based on the string positions returned. When I get the exact name of the notebook of interest, it's easy to close it with NotebookClose[name].

I'll bet there is a very straightforward way to extract properties from notebook objects. But I can't find it.

$\endgroup$
8
$\begingroup$

If the open notebooks have already a filename (ie if they have been saved somewhere) :

NotebookFileName /@ Notebooks[]  

otherwise you can use :

NotebookInformation /@ Notebooks[]
$\endgroup$
  • $\begingroup$ It's so simple. Thanks again. $\endgroup$ – George Wolfe Jan 25 '18 at 20:57
5
$\begingroup$

Does:

AbsoluteCurrentValue[Notebooks[], WindowTitle]

work for you?

$\endgroup$
  • $\begingroup$ I knew there was an easy way. Thanks! $\endgroup$ – George Wolfe Jan 25 '18 at 20:56

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.