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

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

emacs lisp command to copy dir and all subdir?


From: Xah Lee
Subject: emacs lisp command to copy dir and all subdir?
Date: Mon, 24 Aug 2009 20:43:38 -0700 (PDT)
User-agent: G2/1.0

is there a emacs lisp command to copy a whole dir? like unix's cp -R?

i started to write one:

(defun copy-dir (sourcedir destdir)
  "Copy all files from SOURCEDIR to DESTDIR.

The input dir should not end in a slash.
Example usage:
 (copy-dir
 \"/Users/xah/web/p/um\"
 \"/Users/xah/web/diklo/xx\")

Note: no consideration is taken about links, alias, or file perms."
  (mapc
   (lambda (x)
     (let ()
       (when (and (not (string-equal x ".")) (not (string-equal x
"..")))
         (copy-file
          (concat sourcedir "/" x) destdir) ) ) )
   (directory-files sourcedir) ) )

but it is hackish because of the checking with “.” and “..”,
but also realized this doesn't do sub dirs. In order to do subdir,
it'll prob end up with few hours more...

so, am wondering if there's a pre-made solutions?

Thanks.

  Xah
∑ http://xahlee.org/

reply via email to

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