Suppose I have an action like follows:
ClearAll[eventAction];
eventAction[]:=Module[{
$previousPath,
$todaysPath
},
$previousPath=NotebookFileName[EvaluationNotebook[]];
$todaysPath=FileNameJoin[{
NotebookDirectory[],
"NameChangingNotebook - "<>DateString[Today,{"Day","Month","YearShort"}]<>".nb"
}];
NotebookSave[EvaluationNotebook[],$todaysPath]
DeleteFile[$previousPath]
];
How do I make this action execute whenever the notebook save command is sent?
DynamicModule[{},EventHandler[Null,{{"MenuCommand","Save"}:>(eventAction[])}]];
FrontEndToken[EvaluationNotebook[], "Save"]is not working here. Maybe some complex frontend knowledge is required for this task. You can try a binding with the shortkey like Ctrl + S in Windows. – bcegkmqs23 Jan 25 '20 at 15:05
– user13892 Jan 25 '20 at 19:06SetOptions[EvaluationNotebook[],NotebookEventActions->{"WindowClose":>(eventAction[])}]