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.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs

Emacs Tutorial

Emacs Init

Emacs Keys


ELisp Examples

ELisp Write Major Mode

Emacs Lisp


Basic Functions

Writing Command

Writing Script

Lisp Data Structure

Lisp Symbol

Elisp Misc