Swap two names preset

Hi there,
I need a simple preset for swapping the names of two files.
Don't want a button. Thanks for sharing!

Regards, Julian

It would have to be a button and not a rename preset, as rename presets don't know anything about the other files being renamed.

(Please link your account.)

This button has collected a bit of dust, but could probably be turned back into a rename preset.

That old button is from before Opus had general scripting, and is using an old technique to run something that'd now be a normal script via a rename script.

You could technically still do just about anything within a rename script but I don't think it's a good approach when there's a better way. You won't get proper logging and undo support, for example, because the rename script itself.is moving the files around (not just returning the new names it wants).

Thanks for answers so far so I need a script?

Is this example from 2:10 somewhere available?

The script used in the video was this:

function OnGetNewName(getNewNameData)
{
	if (getNewNameData.newname_stem == "A")
		return "B" + getNewNameData.newname_ext;
	if (getNewNameData.newname_stem == "B")
		return "A" + getNewNameData.newname_ext;
}

Useful for demonstrating that Rename now works when an operation ends up swapping two files' names (which can happen easily when numbering files, for example), but not useful for anything else.

If you're OK with a button rather than a rename preset, I can update Jon's old post to use newer methods which will make it better on current versions of Opus. Can't do it right away but should be able to find time tomorrow or Friday. (Jon's post should still work, if you just want something quick and don't care about logging or undo.)

Ah I understand, this was just an example to show the technique behind :slight_smile:

An upgrade for an button would be very kind! No time pressure on my side!
I'm using dopus since 3-4 years, optimized many of the fiddling tasks but swapping names is one of the operations I'm still doing by hand and wanted to optimize.

Generally, your renaming tool is such a great time safer!
I use it all the time that's why I've asked for a preset but a button works also fine for me.

I've updated the old button with new versions that do things in a cleaner way (that wasn't possible at the time the original post was written).

Undo still doesn't work, unfortunately, but we might be able to improve that in the future. (Of course, you can undo things by just clicking the button a second time.) Unlike the old version, logging now works, since the renames are now done using Opus's own Rename command.

1 Like

Works great, thanks!