Duplicate a file then select new file

I am trying to set up a button that duplicates a file and then selects the destination file:

Copy DUPLICATE WHENEXISTS=rename AS "{file|noext} copy{file|ext}"
Select "{file|noext} copy{file|ext}"

however, even though the destination file gets selected here, it seems that the first file still has focus (since if I hit F2 to rename afterward, it renames the original file)

Could someone please tell me what I'm doing wrong?

Thanks!

F2 inline rename works on the file with the keyboard focus and ignores the selection.

What are you actually aiming to do? If you want to be prompted for the new filename, using what you have above as the default, then there's a much better way to do that.

I am trying to duplicate whatever file is selected, prompt for a new filename -

so if original filename was test.txt, the new box could show: .txt
OR BETTER YET, the box could show test.txt with the 'test' letters selected:

then select the new file (so that way if I hit 'enter' it launches it...)

Thanks Leo

Opus does what you want by default. (The arguments you've added to the command are actually taking you away from your goal. :slight_smile:)

Just use this:

Copy DUPLICATE

Ahh... so it does.

What can I add afterward in order to select the new file that is created?

Does the new file name that I enter here in this dialog box get assigned to a variable of some kind, then maybe I could select it afterward?

maybe something like
Select $..... MAKEVISIBLE

The name isn't saved anywhere as far as I know.

I think there's a more general feature-request to automatically select newly created files; if that gets implemented it'd probably solve your problem.

For now, what are you actually trying to do? Why do you want the duplicated file to be selected? For example, if you're going to immediately move it somewhere else then you could do the move-and-rename as a single step and avoid the problem entirely.

Well, it mainly came up when duplicating text files for programming,

ie copy 't_template.pl' to 't.pl' or whatever file name I type in the dialog box, then launch 't.pl' in ultraedit...

Can that be done in 1 button?

This assumes you want to keep the file extension as-is and just type over the name.

Change the Notepad.exe path to whatever your editor path is.

@firstfileonly @nofilenamequoting @set NewName = {dlgstringS|New file name:|{file|noext}}{file|ext} Copy "{filepath$}" HERE AS="{$NewName}" "C:\Windows\Notepad.exe" "{sourcepath$}{$NewName}"

That works beautifully, thanks so much Leo.