5
$\begingroup$

Here is the scenario:

You have number of open notebooks at the same time, and made some changes in all or some of them but have not yet saved the changes.

Mathematica does not have something like save all that will save all and any open files that needs to be saved before closing. (At least I do not see it under File)

So I expected that when one clicks on the close all windows on the main icon, that it will prompt one to save or not save all the open notebooks that needs this action done on them, one by one.

Mathematica graphics

What happens is this: It asks about the first open notebook, then when answering the question, expecting it will now ask about the next open notebook, instead it does nothing. Leaving the remaining notebooks open as is.

So one have to click and click and click again on close all windows until all open notebooks that needs to be saved are saved. So if one has 10 open notebooks, they have to click 10 times on close all windows and click again to answer the question. This is 10 additional clicks.

Other apps I used would ask the user for each open file in turn, or provide a save all or when closing, they would ask the user if they want to save all or discard all, etc...

Is there a way to get Mathematica to do this so one does not have to keep clicking on things? A palette that does save all open notebooks would be great.

Finally, after closing all windows, and with all those clicks, the main Mathematica icon remains there! So one has to click again to quit. (I actually do not see this splash window below at all, until I have closed all windows. It seems to be hidden somewhere during normal operations or while a notebook is open and this only shows up if all notebooks are closed, not sure)

Mathematica graphics

$\endgroup$

3 Answers 3

10
$\begingroup$

Go through the following steps and it will work.

Edit->Preferences->Advanced->OpenOptionInspector And Lookup "ClosingAutoSave" and change ClosingAutoSave from False to True.

If you have any other tweaks you would like to perform, ask away!

EDIT:: I have tried this for Mathematica 10 and it is working.

What this does is automatically save the notebook on each close.

$\endgroup$
3
  • $\begingroup$ does this change the modification time on every notebook you open even if unchanged? $\endgroup$
    – george2079
    Jul 12, 2014 at 15:12
  • $\begingroup$ No, the notebook's Date Modified value is only changed if any contents in the notebook were changed. $\endgroup$
    – mildused
    Jul 12, 2014 at 17:17
  • $\begingroup$ I just found out, this is not the behavior I wanted at all. This has caused me problems. There are times I make a change to the notebook, but then decide I do not want the cnahges, and close the notebook without saving by clicking on "X" corner of the window. It turns out Mathematica now still saves the changes I made ! as it never asks me if I want to save it first as it used to before. This is not what I wanted. I wanted it to ask me if I want to save the changes. So I have rolled out this option back to the way it was. AutoSave is not what I want actually. $\endgroup$
    – Nasser
    Jul 20, 2014 at 19:14
1
$\begingroup$

NotebookSave /@ Notebooks[]; or NotebookSave /@ Select[Notebooks[], (AbsoluteCurrentValue[#, WindowTitle] != "Messages") &]; to avoid saving the Messages notebook.

$\endgroup$
1
$\begingroup$

I use this function:

saveAll[docType_: {"Notebook", "Package", "Script"}] :=
 Map[NotebookSave[#]; NotebookFileName[#] &, 
  Select[Notebooks[], (MemberQ[Keys[NotebookInformation[#]], 
       "FileName"]) && (StringMatchQ[
       "DocumentType" /. NotebookInformation[#], docType]) &]]

it returns the list of saved files.

Note: the "*" in the window title of the Notebook you used to run this function will be still present. This is not because your notebook has not been saved, but because it is modified by the saveAll[] function output. If you do not want this behaviour you can replace Map by Scan. With Scan the function will not generate output.

$\endgroup$

Your Answer

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

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