If I want to do recursive hardlinks of a directory I have to use cp -r -l dir in bash instead of ln -h. How do I replicate this in dired, because dired-do-hardlink uses ln underneath?

I can use M-! cp -r -l dir but I would like to not have to treat directories differently when linking files around.

1 Answer 1


Use diredp-do-hardlink-recursive, from library Dired+.

diredp-do-hardlink-recursive is an interactive compiled Lisp function
in `dired+.el'.

(diredp-do-hardlink-recursive &optional IGNORE-MARKS-P)

Add hard links for marked files, including those in marked subdirs.
Like `dired-do-hardlink', but act recursively on subdirs to pick up the
files to link.

The files included are those that are marked in the current Dired
buffer, or all files in the directory if none are marked.  Marked
subdirectories are handled recursively in the same way.

With a prefix argument, ignore all marks - include all files in this
Dired buffer and all subdirs, recursively.
  • It always impress me that you will know an answer to almost everything, Drew.
    – ReneFroger
    Feb 23, 2016 at 23:05
  • If I install dired+ using package-install I lose default dired behavior. How do I just use dired as a library of functions?
    – salotz
    Feb 23, 2016 at 23:28
  • You lose what default Dired behavior? Dired+ is a superset of Dired. Please be specific - perhaps the same behavior is there, but not where you are looking for it.
    – Drew
    Feb 23, 2016 at 23:48
  • 2
    @ReneFroger: Not at all. I know nothing about most of the things asked here - nothing about Org or Spacemacs or Prelude or AUCTex or.... I do know some things about a few parts of Emacs. Dired is one of those parts. Anyone would, after spending a lot of time trying to customize things - like you all are doing. Spend as much time with the Dired code as I have (over a long period of time) and you are bound to have picked up a few things. It's the same story for everyone, really.
    – Drew
    Feb 23, 2016 at 23:52
  • 1
    If you don't want to load Dired+ for some reason then you can dig out the relevant code from it and use that. Command diredp-do-hardlink-recursive is what you need, but it is defined in terms of diredp-get-confirmation-recursive and diredp-do-create-files-recursive (which is defined using diredp-get-files).
    – Drew
    Feb 24, 2016 at 19:25

Your Answer

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

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