I've added this feature now to Dired+.
You can use C-y
(command diredp-yank-files
) to paste files, whose absolute names you have copied to the kill ring, to the current directory. The "current directory" here is what dired-current-directory
returns: the inserted subdirectory where the cursor is located, or the Dired main directory if the cursor is not in a subdir listing.
With a prefix arg, C-y
instead prompts you for the target directory for the paste. So you do not need to be in a Dired buffer to paste files to a directory.
You should have copied file names to the kill ring using M-0 w
or M-x diredp-copy-abs-filenames-as-kill
.
In Dired+ those commands also set variable diredp-last-copied-filenames
to the
same string of file names. C-y
uses the value of that variable, not
whatever is currently at the head of the kill ring. This means that you need not paste immediately after you copy file names. And it means that you could, instead of copying file names to the kill ring, just put the names in that variable (e.g. programmatically).
When you use C-y
, you are prompted for confirmation (y
or n
). You can also hit l
(for "list") when prompted, to display the list of files that will be pasted.
You can also copy the marked files from the current Dired buffer and any marked files in its marked subdirectories, defined recursively. For that you use M-0 M-+ M-w
(zero prefix arg with command diredp-copy-filename-as-kill-recursive
) or use M-x diredp-copy-abs-filenames-as-kill-recursive
.
Note that with Dired+ you can also easily have a Dired buffer that lists any number of files and directories, from anywhere. That is, the entries listed need not be in the same directory or even in related directories. See C-x D F
(command diredp-dired-for-files
), which is on the Dir menu-bar menu as item Dired Files Located Anywhere. You can mark and then paste (copy) such arbitrary files from a Dired buffer to any directory.
Update 2019-04-22:
I also added the ability to move (not just paste) the files whose (absolute) names you copied to the kill ring to the current (or another) directory. This is bound to C-w
in Dired.
diredp-move-files-named-in-kill-ring
is an interactive Lisp function
in dired+.el
.
(diredp-move-files-named-in-kill-ring &optional DIR NO-CONFIRM-P DETAILS)
Move files, whose absolute names you copied, to the current directory.
With a non-negative prefix arg you are instead prompted for the target directory.
With a non-positive prefix arg you can see details about the files if
you hit l
when prompted to confirm pasting. Otherwise you see only
the file names. The details you see are defined by option
diredp-list-file-attributes
.
You should have copied the list of file names as a string to the kill
ring using M-0 w
or M-x diredp-copy-abs-filenames-as-kill
.
Those commands also set variable diredp-last-copied-filenames
to the
same string. diredp-move-files-named-in-kill-ring
uses the value of
that variable, not whatever is currently at the head of the kill ring.
When called from Lisp:
- Optional arg
NO-CONFIRM-P
means do not ask for confirmation to move.
- Optional arg
DETAILS
is passed to diredp-y-or-n-files-p
.