Custom rename commands

If I understand correctly, the Advanced Rename script only allows generation of new file names, but the actual rename operation is handled internally by DOpus. It would be great if we could specify a custom command/script in Advanced Rename for the actual operation too. In other words, instead of standard windows file rename command (like move <oldName> <newName>), I'd like to use a command like git mv <oldName> <newName> to perform a git rename for each file during the rename process.

Do you want a script to generate the names as well? Or do you want to use the non-scripting parts of the rename dialog and then feed the results into another program?

I mainly want to feed the results to a custom program one by one in my case. The ability to write a script for generating the names exists already. I'd like to use the existing features as they are. Just the program/command used for renaming is not customizable and that's what I'd like to change. As in my example, in DOS, we'd rename a file using ren or move command. Instead I want to use a custom command with parameters like myRenamerProgram $oldname $newname to perform the rename after the names have been generated.

We could potentially add an event that rename scripts could implement to do the actual rename in place of the internal rename code. That would work for things that rename one file at a time.

Maybe some things would want to be fed the whole old/new name list of all files at once though?

(FWIW, rename scripts can kind-of do this already, as nothing stops them doing things which had side-effects, such as modifying files or calling external programs. The problem is that scripts currently have no way to know if they're being run to generate the interactive preview of what the names will be, or for the actual rename. Scripts with side effects can work well in buttons where the Rename dialog is never displayed, but when used in the dialog their side-effects end up being applied before you even click OK/Apply.)

Something like an event sounds good. As you mentioned, doing it within current rename scripts may not be best since they won't know the current execution context. So, I was thinking of leaving existing rename script section as is (just for generating the file names) and create another optional script (let's call it operation script) where we could change the actual command used for renaming. Maybe it can accept the whole list at once and the users may decide in the operation script whether to process it one at a time or all at once. In this case, regardless of whether we use custom rename script or just some of the options in the rename UI (check boxes and input boxes for various renaming options), one can customize just the execution of the final rename operation itself. This certainly has the advantage of letting users use the existing UI options for the custom rename operation.

Maybe I'm unaware if existing rename script already allows use of the other UI options alongside the script at the same time.

Scripts get run on each file after all the other options in the dialog are applied to the names, and have access to both the original/current filename and the proposed new file name. (They can ignore either or even both if they want to, but they have both if they need them.)

Something I didn't think of before: There is an OnFileOperationComplete event which script add-ins (not rename scripts) can implement to be notified when files are about to be renamed and then when they have been renamed.

That event would let you run custom commands in response to file renames, e.g. if the files are below a source-control folder.

But note that the event cannot prevent the rename from happening; it's only notified of it before and after it completes.

That certainly seems like a good option. If the event can get the ability to cancel the rename operation, I think it can work as what I was asking for.

Now when I was about to implement it, I realized that certainly having a custom rename action/command option in the rename dialog would be a really nice addition. The OnFileOperaionComplete event is only triggered before or after the rename. Hence, for things like source control, one of the operations - the rename operation or the source control command - will fail unless we use some weird hacky workarounds. I want to do git mv <old file> <new file> for each file instead of move <old file> <new file>.

You would have to write a VFS Plugin if you wanted to automate source control from normal file actions like that. That's possible but a lot more complicated.