Rename Dialog sequential Numbering downwards

Greetings Opi Community

Is there an easier way to do this?

Often I want to add suffixes to groups of files in the form shown in the Objective screenshot:

This is my Current Method using the very cool Rename Dialog:

Lost of click and edits as you can see.
This is what I would like to do:

Maybe...one day!

Maybe I am missing something... the only "real" problem seems to be to automatically append the number of selected files. Isn't reversing both the file order and the numbering order at the same time like doing neither?

Hi @Ixp
It seems not possible to reverse the numbering order. By numbering order I assume you mean putting a minus sign (-) in the "By" field. I reverse the file order a as a workaround.

I see. But isn't the workaround the smarter approach anyway? It frees you from having to figure out the total number of files.

Nonetheless, having the total number of files selected/renamed readily available seems like a useful feature ("Image x of xx").

I also like the idea of having a "to" field that lets you set the end number instead of the start number. Could be an extra field or the existing "from" with a negative increment.

Or we go full nerd mode and set from and to and let Opus compute the needed increment :crazy_face:

1 Like

Can be done easily with a script, if you don't mind it being a standalone button, and also each file (instead of the whole batch) having a separate undo entry:

Try on some disposable test files first, in case it doesn't do exactly what you need.


Script code for reference (contained in the .dcf file above):

function OnClick(clickData)
{
	var pad = 2;

	var cmd = clickData.func.command;
	cmd.deselect = false; // Prevent automatic deselection
	var selected = clickData.func.sourcetab.selected;

	var count = selected.count;
	var current = count;
	var wild = DOpus.FSUtil.NewWild();

	for (var eSel = new Enumerator(selected); !eSel.atEnd(); eSel.moveNext())
	{
		var item = eSel.item();
		var oldPath = wild.EscapeString(item.realpath);
		
		var newName = item.name_stem_m;
		newName += " P" + ZeroPad(current--, pad);
		newName += "_" + count;
		newName += item.ext_m;

		var cmdLine = 'Rename FROM="' + oldPath + '" PATTERN=* TO="' + newName + '"';
		DOpus.Output(cmdLine);

		cmd.ClearFiles();
		cmd.RunCommand(cmdLine);
	}
}

function ZeroPad(s,c)
{
	s = s + "";
	while(s.length < c)
	{
		s = "0" + s;
	}
	return s;
}

Well I got more then I bargained for with this post!
Thanks gents.... Amazing! Opus keeps on giving! Stupendous!!!!!

1 Like