Insert selected filename while copying in Midnight Commander

file-copymcrename

Is it possible to paste the selected filename into the copy popup, so when I hit F5 this filename will be in the 'to' section, so I can adjust it?

For example:

I want to copy /home/piotr/testFile.log to /home/piotr/testFile2.log.
I open both panels in the same directory and hit F5, but the 'to' value is: /home/piotr and I would like it to be /home/piotr/testFile.log, so I can simply adjust the name instead of typing it from the scratch.

Best Answer

Use Shift-F5 instead (or Shift-F6 for renaming) – the dialog will have the to field filled with current file's name (without the path).

Sadly those combinations not work in certain circumstances. No idea if it depends on MC build, terminal or some used library. So I also added this in ~/.mc/menu as an alternative:

5       Copy
        read -e -i "%f" -p 'Copy file : ' name
        [[ "$name" && "$name" != "%f" ]] && cp "%f" "$name"

6       Rename
        read -e -i "%f" -p 'Rename file : ' name
        [[ "$name" && "$name" != "%f" ]] && mv "%f" "$name"

Then I just select the file, hit F2, 5 (or 6 for renaming) then edit the name and press Enter. It requires bash 4 or newer, due to the read's -i option.

Related Question