help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I apply a function to all file in a directory,recursively?


From: Kai Großjohann
Subject: Re: How can I apply a function to all file in a directory,recursively?
Date: Mon, 26 May 2003 10:41:09 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

Wang Yin <wang-y01@mails.tsinghua.edu.cn> writes:

> I need some elisp code that can apply a function (actually,
> semanticdb-get-database) to all file in a directory and it's
> subdirectories recursively.

The function directory-files gives you a list of files and
directories in a directory.  You can then examine each element of the
list whether it is a directory.  If it is, call yourself recursively.

(defun walk-subtree (dir)
  (mapcar (lambda (f)
            (setq f (expand-file-name f dir))
            (if (file-directory-p f) 
                (walk-subtree f)
              (message "Found a file: %s" f)))
          (directory-files dir)))

-- 
This line is not blank.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]