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."
  (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

If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial

Emacs Tutorial

Emacs Init

Emacs Keys


ELisp Examples

ELisp Write Major Mode



Basic Functions

Writing Command

Writing Script

Lisp Data Structure

Lisp Symbol

Elisp Misc