6
$\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$

2 Answers 2

9
$\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$
1
  • $\begingroup$ It's so simple. Thanks again. $\endgroup$ Jan 25, 2018 at 20:57
6
$\begingroup$

Does:

AbsoluteCurrentValue[Notebooks[], WindowTitle]

work for you?

$\endgroup$
2
  • $\begingroup$ I knew there was an easy way. Thanks! $\endgroup$ Jan 25, 2018 at 20:56
  • $\begingroup$ @Carl Woll: Is there a way like your suggestion above to list the names of all the variables and tagged cells in a notebook? $\endgroup$ Dec 10, 2019 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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