Rename then copy MOVE a file fails because windows still thinks file has old filename

Isn't this what we already discussed in Esc* modifiers eat backslashes - #4 by Leo ?

My advise there: Instead of "{alias|xyz|escregexp}\\1"
use "{alias|xyz|noterm|escregexp}\\\\1"

(And maybe add @nofilenamequoting as well, although it seems to be optional.)

Hi @Leo indeed honestly i am not understanding that bug.
I thought the bug applied to parameters outside the {}? Not sure though.
Adding noterm| and \\ as instructed made no difference see below.
Not sure how to use @nofilenamequoting in FAYT. Is that possible?

I'm not sure I follow your diagram.

What's the file path being renamed?

What is the a120 alias defined as?

Have you tried adding @nofilenamequoting?

With going back to a regex rename the old problem (probably a bug) came back: \1 needs an additional \ when it's the first component of the new file name. So your script needs to replace Str_Suffix with \ if it is empty.

@slouw I don't follow you seriously. Does your script do anything more complicated than the screenshots you show or why do you need to use regex there? Or codes like {alias} that are more intended to be used outside of scripts and also have their equivalents. A simplified way to approach your problem would be:

function OnClick(cmdData) {
	DOpus.Output('START!!');
	var dest = cmdData.func.dlg.GetString('Enter alias name', 'al20', 100, 'Ok|Cancel', "Alias Name");
	if (!dest) return;
	var suffix = cmdData.func.dlg.GetString('Enter suffix');
	if (suffix === undefined) suffix = '';
	try {
		dest = DOpus.Aliases(dest).path;
	}
	catch (e) {
		DOpus.Output("You're screwed!!");
		return;
	}
	if (!DOpus.FSUtil.Exists(dest)) {
		DOpus.Output("You're screwed again!!");
		return;
	}
	var cmd = cmdData.func.command;
	var cmdline = 'RENAME IGNOREEXT PATTERN=* TO="' + dest + '\\*' + suffix+'"';
	DOpus.Output(cmdline);
	cmd.RunCommand(cmdline);
	DOpus.Output('DONE!!');
}

Testing with your examples gives me no errors. The example is simplified since you don't show the whole process you are doing or what you need it for. For your example I think COPY MOVE would also work and use AS if you need to add a suffix, but I don't see the need to use regex, at least in your example.

I am working on removing Regex. I know you removed that with one of my 4 rename strings you helped me with. Thanks....

@errante thanks. I have wondered ineed if I have the best approach.
I will just respond to @Leo and @lxp above then i will look into your script. Much appreciated...

Let me guess: you never tried with more than one selected file :wink:

:smile: You're right. Corrected and tested with multiple selection. Is it OK now?

Haha I have a bit. I know that is the next thing to test.
This has turned into Ben Hur double haha :slight_smile:
Public holiday in Aus today so will work on this more...