Elisp: Get Dired Marked Files

By Xah Lee. Date: . Last updated: .

To get marked files in dired, use dired-get-marked-files

Then, you can map a function to all the files.

;; apply a function to dired's marked files

(require 'dired)

(defun xah-open-dired-marked ()
  "Open marked files in dired."
  (interactive)
  (mapc 'find-file (dired-get-marked-files))
)

;; test
;; M-x dired, then mark some files, then M-x xah-open-dired-marked

;; replace find-file to your own function

Elisp: Writing Command

  1. Writing Command, Basics
  2. Mark and Region
  3. Get Buffer String
  4. Work with Lines
  5. Copy Cut Paste kill-ring
  6. Get User Input
  7. Interactive Form
  8. Get universal-argument
  9. Find Replace Text
  10. thing-at-point
  11. Get Dired Marked Files

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs

Emacs

Emacs Lisp

Misc