File name copying and renaming another file - automation?

I often have to copy a filename in one directory and use it to rename a file in another directory that has a different filename and extension. The source file is in one viewer pane and the destination file, that is the file to be renamed, is in the other viewer pane. Since Ctrl+Shift+N copies the filename including the extension what I normally do is:

Assuming by way of illustration that the two files are called "proper_name.srt" and "to_be_renamed.avi" respectively:

  1. Select the source file (proper_name.srt).
  2. Press Ctrl+Shift+N (copy the filename including extension)
  3. Tab into the other viewer pane.
  4. Select the destination file (to_be_renamed.avi).
  5. Press F2.
  6. Press Ctrl+V to paste the filename including extension (proper_name.srt) from the clipboard. The destination file name, in edit mode, becomes "proper_name.srt.avi". The cursor is after the "t" of "srt".
  7. Backspace four times to delete the source file's extension ("srt") and the separator dot from the destination file name.
    [8. After the above tasks I also move the renamed destination file (now named proper_name.avi) from one viewer pane to the other, ending with two files in the same directory called proper_name.avi and proper_name.srt respectively].

Ideally I would like to automate this process, realistically into two steps. That is, a button or keyboard shortcut to automate steps 2 and 3 and another one to automate steps 5, 6 and 7.

As a second best solution I would be quite happy to find a way to paste the filename only in step 6, that is without the extension. This way I will avoid having to carry out step 7.

Button 1:

@nofilenamequoting
Clipboard SET {file|noext}
Set SOURCE=toggle

Button 2:

@nofilenamequoting
Rename PATTERN * TO "{clip}{file|ext}"

Actually, you can do the whole thing with just one button, and without trashing your clipboard in the process. Select the file whose name you want to use, then select the file you want to rename in the other folder. Doing it in that order, the file to be renamed should be in the Source and the file with the name you want to take should be in the Destination. Then just click this:

@nofilenamequoting
Rename PATTERN * TO "{filedest$|noext}{file|ext}"

Thank you very much for such a quick and totally excellent reply.

Buying DOPUS is turning out to be one of the best software purchases that I've ever made! :slight_smile:

1 Like

I would like to rename files from the source pane to the destination pane without copying the file extension, will this code allow me to copy multiple file names from source to destination?

Will this code work if I want to add this to the context menu?

How do you create a button?

:thumbsup:

For those of you that would like this feature adding to your context menu (right-click in dopus), here is a step-by-step explanation.

Go to Settings, and select File Types.
Select 'All Files and folders', and then click Edit.
Select the 'Context Menu' tab, and click 'New'.

Label your new action, I called this action 'Duplicate file names'.
Change the function dropdown to Standard Function (Opus or external)

In the function editor, enter the command Leo suggested:

@nofilenamequoting
Rename PATTERN * TO "{filedest$|noext}{file|ext}"

Click OK, then OK, and then Close.

How to use this function: Simply select the source file name/multiple file names you want to copy in the first lister view, then select the destination files you want to rename (second lister view), right click and select Duplicate file names.

Enjoy :thumbsup:

If you wanted, you could also add the "move" operation of step 8 to the button or context menu item as well. Then you wouldn't need to do anything after renaming the file.

Hey Leo,
How can I have a similar function that works if both files are in the same folder? I tried the one you mentioned but it doesn't work.

Thanks!

Elad.

You could use the Inline Rename.

You can copy the name from the previous file by pressing Ctrl+Shift+Up (or Ctrl+'), or from the next file by pressing Ctrl+Shift+Down (hold the Alt key down as well to also copy the extension). Continue to press the keys to move up/down the list of neighboring files to copy their filenames.

https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Inline_Rename.html

Hey

Thank you! but very often in my case the files are not below/on top of each other but totally out of order due to unrelated naming.

I usually just hit F2, Ctrl-C on one file, then F2, Ctrl-V on the other.

Would automation help much here? Maybe if you're doing it to hundreds of files, but you'd still have to do something to one, then the other (to define which order it happens in), so I don't know that you can save much time vs doing it manually.

Hey Leo

It's true it doesn't save that much time, just 3 clicks (with a button) vs. click-F2-ctrl-c-click-f2-ctrl-v
I just liked the idea of having a button for this (which with a shortcut would be even quicker)

Since I saw the command before I figured maybe it's just new syntax that is required to make it work
Otherwise I'll keep doing it as you are..no worries :slight_smile:
thanks!

You could speed things up a little by having a pair of hotkeys to copy and replace the names, which saves a keystroke for each, I suppose:

@nofilenamequoting
Clipboard SET {file|noext}
Rename PATTERN * TO "{clip}" IGNOREEXT

(They're similar to the commands above, but without switching source/dest sides, and using the newer IGNOREEXT argument, which didn't exist back then, to preserve the extension in a slightly better way.)

A post was split to a new topic: Rename .srt file based on .mkv in same folder