5

windows 10, emacs 25.1, dired+

Suppose in folder I select 3 files. Something like this:

dired_select

Now I want 2 options:

  1. Copy to kill-ring the selected files names. So the result must be:

    ic_contact_us_write_us.png

    ic_in_store_green.png

    ic_m_brands_active.png

  2. Copy to kill-ring the full path of selected files names.

So the result must be:

d:/TEMP/1/drawable-hdpi/ic_contact_us_write_us.png

d:/TEMP/1/drawable-hdpi/ic_in_store_green.png

d:/TEMP/1/drawable-hdpi/ic_m_brands_active.png

Is it possible?

6

You can copy file names by pressing w. It calls the function dired-copy-filename-as-kill:

(dired-copy-filename-as-kill &optional ARG)

Copy names of marked (or next ARG) files into the kill ring. The names are separated by a space. With a zero prefix arg, use the absolute file name of each marked file.

Hence, in order to copy the full path of marked files to the kill ring, I've added the following piece of code:

(defun tl/dired-copy-path-at-point ()
    (interactive)
    (dired-copy-filename-as-kill 0))

(define-key dired-mode-map (kbd "W") 'tl/dired-copy-path-at-point)
  • Also a universal argument works: C-u 0 M-x w (I just learned) – RecencyEffect Oct 16 '18 at 6:29
  • This answer should be updated. The interactive command dired-copy-filename-as-kill is correct, but the advice should really be to use the universal argument directly rather than defining another command. Simply use C-u 0 w (@RecencyEffect's comment probably contains a typo). – ebpa Mar 15 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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