How to rename a file from text in the clipboard

I'm trying to rename a file from text in the clipboard with this command in a button: Rename FROM "{file}" TO="{clip}"

I get the following error box:

Screen 23-12-26 12_01_06AM

Test 3 is the name of the file to be renamed.

If I click on Replace, the rename takes place.

How can I avoid the error message? TIA

may be this?

What’s in the clipboard?

Does something already exist with that name? That’s what the message seems to be saying.

If a folder with the same name exists, you need to add IGNOREEXT.

The two filenames are different.

I tried this but I got the same error box.

I tried this but received the same error box.

I'd use something like

@nodeselect
Rename TO="{clip}" IGNOREEXT

but your command looks alright, too.

Actually, I'd just hit F2 and Ctrl-V :wink:

I have narrowed the issue.

Both Rename FROM "{file}" TO="{clip}" IGNOREEXT and
@nodeselect
Rename TO="{clip}" IGNOREEXT
work
WHEN the file to be renamed is in a different folder.

If the file that is the source for the rename and the file to be renamed are in the SAME folder then the error box pops up.

The command works fine, but I think you're confused about what it does.

There's only one file and directory involved in the command: The file you're renaming and the directory it's in.

If you're thinking about a "source for the rename and the file to be renamed" as two separate things, I assume you're selecting a file and using Ctrl-C to put it into the clipboard as you would when doing a copy & paste file copy.

But {clip} inserts the clipboard text. It doesn't do anything if a file is in the clipboard.

You could do that via scripting, however. Or use this, in the Edit menu, to copy the other file's name to the clipboard instead of the file itself:

image

I was using Ctrl+Shift+N to load the clipboard with the file name not the file itself.

I am satisfied with the code in post 8 above.

What I would like is a single button to run F2 and Ctrl+V. This would leave me in this position where I could edit the file name:

Unfortunately, putting these same commands in a single button only opens edit mode but does not insert the clipboard text.

So you were trying to rename one file with the name of another file in the same folder? The error message is accurate in that case. You can't have two files with the same names.

1 Like

I hope this button can help you
Renombrar con Portapapeles.dcf (1.2 KB)

1 Like

Thanks for your suggestion.