In Emacs dired, how do I select files based on names from a list?

149 Views Asked by At

I open a buffer in emacs dired and select some files. How would I go about selecting files with the same name in another buffer? Ex: I select files a.txt, k.txt and z.txt in folder A. I then open a folder B in dired...how could I mark the files with the same names in folder B?

1

There are 1 best solutions below

2
choroba On BEST ANSWER

The following elisp code worked for me with buffers dired1 and dired2.

(progn
  (switch-to-buffer "dired1")
  (dlet ((files (mapcar (lambda (path) (car (last (split-string path "/"))))
                        (dired-get-marked-files))))
    (switch-to-buffer "dired2")
    (dired-mark-sexp '(member name files))))