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

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

Re: emacs lisp command to copy dir and all subdir?


From: Xah Lee
Subject: Re: emacs lisp command to copy dir and all subdir?
Date: Fri, 11 Sep 2009 22:24:31 -0700 (PDT)
User-agent: G2/1.0

here's my draft implementation. (thanks for Andreas Politz)

For those who wish to use, here it is. Tested and used for my own
script that used to depend on unix's cp.

(defun copy-directory-recursive (source-dir dest-dir)
  "Copy whole a directory SOURCE-DIR to DEST-DIR.
Note, the semantics of source-dir dest-dir is different from the unix
“cp” utility.
In unix's “cp -R”, if dest-dir exists, it'll copy source-dir itself,
else, just source-dir's children.

In copy-directory-recursive, it always copy source-dir's children.

In both, the dest-dir may or may not exist. If not, it'll be created.
However, dest-dir's parent must exist.

This function is based on dired-copy-file-recursive.
Behavior about linked files, etc, are from that function."
  (require 'dired-aux)
  (dired-copy-file-recursive source-dir dest-dir nil nil nil 'always)
  )

haven't worked on delete-directory-recursive yet...

the unix cp is idiotic...

• Idiocy Of Unix Copy Command
  http://xahlee.org/UnixResource_dir/writ/unix_copy_dir.html

  Xah
∑ http://xahlee.org/

reply via email to

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