Scripting event OnBeforeFileOperation

I want to make an add-in which prevents accidental modifying file operations such as delete, move, rename etc. when in certain user-defined paths. The add-in would warn the user that the location is marked as integrity critical (maybe it's svn server repository, backup destination or whatever) and either allow to proceed or cancel.

For that I'd need some kind of OnBeforeFileOperation scripting event with file operation ID so I can determine which file operation triggered it. It must be possible to either continue or cancel the operation (like existing OnDoubleClick event has by returning true or false).

I'd like to do it for Opus 12 using its new extended script GUI capability so that the add-in will have a nice configuration UI so it makes sense for this scripting event to be available from Opus 12.

You can edit the drag & drop filetype event(s) and the Copy Files, Move Files, Delete and clipboard Cut buttons/hotkeys to run your command before the main commands to do this now.

(You may not even need a script, if @ifpath already covers what you need.)

Using file permissions to make it actually impossible for your account to modify the folder is often better, though. That is what I do*. (And if you make it so Administrator can modify the folder, you can still do things via a UAC prompt, while preventing accidents.)

(*In my case, it's not so much me that I am worried about, but annoying software like Windows Media Player which has been known to re-write metadata and reduce the resolution of coverart of its own accord.)

I didn't think of that, thanks for the ideas! Still, using the add-in with UI for managing paths (and whatnot) would be cleaner all-in one solution.

(also I can't change permissions in all cases as the locations I'm browsing are on the remote computer on network which I have no direct control over)

I expect it could be PITA to implement such scripting callback, but what do I know perhaps it could be reasonably achievable?

You can call your script command from the buttons/events as I described above, and having that command then refer to its configuration (as defined in Preferences for the script), or show its own custom UI.

No need for new callbacks that I can see.

Maybe you agree, something like a "OnBeforeFileOperation" event would be far more elegant and versatile than reconfiguring every button/menu/context menu and hotkey. I did the latter to catch and log items affected by any delete/copy/move in the LogCommand script-addin. It's not a joy to do and cannot be undone quickly.

Consider looking at that "LogCommand" thing, perhaps you can pull something out of it. It's not the latest version but still useful to see a possible implementation I guess. I actually run something very similar to what you have in mind, I catch delete ops for specific paths in the LogCommand version I have here.

Interesting, thanks tbone!