4

I am wondering how to make renaming files in dired to use the current file extension as the default.

For example, imagine I run dired-do-rename on the file foo.bar and then type foo2 and press Enter. I would like the result of this operation to yield the file foo2.bar in my directory.

1
  • There are so many possibilities for what someone might prefer as the default behavior in such a case. Keep in mind too that the single-file rename is not the general or typical use case for dired-do-rename. There is option dired-dwim-target, but its "do-what-I-mean" behavior is not what you mean (;-)).
    – Drew
    Jun 10, 2019 at 22:29

1 Answer 1

2

Don't use dired-do-rename for your use case. Just do this:

  1. C-x C-q to make the directory listing editable (writable).

  2. Insert 2 in the name where you want it (or otherwise edit the name).

  3. C-x C-q to make the listing read-only again.

You can use any editing commands and keys you like: M-% (query-replace) etc.

1
  • Thanks. But I can still get this behavior by using M-n following dired-do-rename. What I would like is the default suggestion following either dired-do-rename or Wdired to contain only the extension with the cursor placed before the period. I occasionally rename long filenames and would still benefit from a default of the current extension although I wouldn't want to default to the whole filename and manually delete everything besides the extension.
    – Jay
    Jun 18, 2019 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.