[Closed] Always Prompt for Save Overwrite?
Is there a way so that when you click save or Ctrl+S it will always prompt you if you’re about to overwrite a file? The number of times i’ve accidentally overwritten something doing this is a bit frustrating, especially when you lose and important file.
I’ve written my own saving script which I use most of the time and it always prompts me, but I want to see if I can build this into max.
Dave Wortley
#filePreSave: string
Sent before a file is saved.
Calling callbacks.notificationParam() returns a String containing the file name.
A pre save callback? But it would not help much I think since it doesn’t know if you want to override or not… maybe create a backup of the file before it saves and restore and increment when overridden with a post save?
There’s always the “auto increment on save” option in the preferences that makes sure you’ll never override another file again.
And there is “incrementalSave” from martin breidt
Keep us updated on your progress, I would be interrested!
-Johan
General Event Callback Mechanism
i was thinking of #filePreSaveProcess too as a possible option. That way, the save process hasnt actually started before the interuption. Also, you can use the notificationparam() array from this type to filter out autosaves – im guessing you wouldn’t want the dialog to pop up every time max saves in the background.
However the biggest issue with this is that i do not know if there is a way of cancelling the save request after the result of a querybox. if not, replacing the max save rather that a scripted one seems difficult.
I guess if nothing else you could…
A. rename the original file, then in #filePostSave rename it back; not as clean as halting a save
B. temporarily switch the original file’s attributes to read-only, then auto-close the read-only warning using dialogMonitorOps+UIAccessor, then change the attributes back to original.
B should certainly do the trick
I’ve written my own saving script which I use most of the time and it always prompts me, but I want to see if I can build this into max.
Replace Ctrl+S with your macro. Or am I missing something?
Well that works but doesn’t help you when you go File – Save instead.
I’m sure everyone can recall a moment when they’ve gone to click Save-As and hit Save instead.
I do like to use incremental saving hence why i’ve written my own script for our pipeline but when working with a complex XREF setup we need to keep the file names the same.
I’ve never actually used any Pre**** scripts so don’t know how to impleament them.
Dave,
Again have a look at martin breidts script incremental save, it keeps the file to a base name and store the old increments in a subfolder, great for XREFfing. And you can always just delete stuf from the menu if you don’t want to accidently hit the wrong button.
-Johan
Yes I know the Incremental Script, have used it before, but it still doesn’t stop my problem of when you want to click save-as and hit save by accident, it may sound really petty but when i’m knocking out hundreds of tests I need to have every single max file incase I need to go back to one, and martin’s Incremental save script would lose my naming convention thus breaking the link between rendered image file name and maxfile name that we have setup and works very nicely for us.
in that case, if it’s for the time you accidentaly hit ‘save’ instead of ‘save as’ can you not just enable “backup on save” in file preferences? then you will have the old file stored in autoback/maxback.bak should you click the wrong choice.
to save I always hit ALT-F, S
to save as I always hit ALT-F, A
I have incremental save bound to ctrl-shift-s
works great for me.
global safeSave
struct safeSave_s (
f = undefined,
fReadOnly = undefined,
fn closeReadOnlyWarning = (
local hwnd = dialogMonitorOps.getWindowHandle()
if (uiAccessor.getWindowText hwnd == "IO Error") then (
UIAccessor.pressDefaultButton() hwnd
dialogMonitorOps.unregisterNotification id:#safeSave
setFileAttribute f #readOnly fReadOnly
dialogMonitorOps.enabled = false
dialogMonitorOps.interactive = false
)
true
),
fn preSaveCheck = (
local np = callbacks.notificationParam()
local id = np[1]
if (id == 1) then (
f = np[2]
if (doesFileExist f) then (
if (not (queryBox "File exists. Overwrite?" title:"Warning - file exists!")) then (
fReadOnly = getFileAttribute f #readOnly
setFileAttribute f #readOnly true
dialogMonitorOps.enabled = true
dialogMonitorOps.interactive = false
dialogMonitorOps.registerNotification safeSave.closeReadOnlyWarning id:#safeSave
)
)
)
),
fn init = (
callbacks.removeScripts id:#safeSave
dialogMonitorOps.enabled = false
callbacks.addScript #filePreSaveProcess "safeSave.preSaveCheck()" id:#safeSave
dialogMonitorOps.unregisterNotification id:#safeSave
true
),
initialized = init()
)
safeSave = safeSave_s()
Could be extended with an no-hands-on auto-increment, etc. but would take more poking around, seeing as maxFileName can’t be changed.