Select last file - rename - then move

I'm trying to make a button that selects the last file, then does a MOVE AS on the same file (new file name is derived from the clipboard).
What I have so far:

Select LAST 
Copy {filepath$} MOVE AS "{clip}{file|ext}"

I tried with {filepath} instead of {filepath$}. Either way the file is only selected, and not renamed/moved until the button is clicked a second time.
Any way around this?

Only use the Select command if you want to select files in the UI, not to change which files subsequent commands will work on. (That works sometimes, but it will often not do what you want/expect.)

Sometimes you can run the command via dopusrt to make it reevaluate what is selected, but that won't work here due to needing {file|ext} to be the thing you want it to be.

It's best to use a script for this kind of thing. Then you can be explicit:

New Button.dcf (320 Bytes)

function OnClick(clickData)
	var cmd = clickData.func.command;
	cmd.ClearFiles(); // Ignore any initial selection.
	var lastFile = null;
	for (var e = new Enumerator(clickData.func.sourcetab.files); !e.atEnd(); e.moveNext())
		lastFile = e.item();
	if (lastFile == null)
	cmd.RunCommand('Copy MOVE AS="{clip}{file|ext}"');
1 Like

Thank you!