help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rename file in dired based on current [T2C round 3]


From: Emanuel Berg
Subject: rename file in dired based on current [T2C round 3]
Date: Wed, 28 Oct 2020 04:53:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

T2C - The Emacs Challenge Competition - round 3

How do you rename a file in dired, and get the previous/current as
a suggestion?

Let's say it is called salma-hayek.png and you want to rename it
salma-hayek-bandidas-2006.png, it is useful to get the first part
spelled out, right?

(defun dired-do-rename-suggest ()
  (interactive)
  (let*((file     (dired-get-filename))
        (old-name (dired-get-filename 'no-dir))
        (new-name (read-from-minibuffer "rename to: " old-name)) )
    (dired-rename-file file new-name nil) ; (NOT) OK-IF-ALREADY-EXISTS
    (revert-buffer) ))

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]