When I use tramp to open a remote directory (say C-x C-f /ssh:user@example:/somedirectory), it opens up a dired buffer for that remote directory. The problem is that I want to copy directories and or files from the remote server to my local machine. I've tried a few syntaxes like marking all the directory or files, pressing 'C', and specifying local:/somelocaldir or just /somelocaldir, but at best the files get copied onto a file somewhere on the remote server.

Is there a way to copy files from a remote (tramp) dired buffer to a local dir? I've only been using emacs 6 months, so if there's a completely different approach that is better and still lets me use emacs (preferably w/ dired), that would be great.

Just to clarify, I'm not interested in viewing, editing, listing, etc. remote files. I just want to copy files from a remote server to my local machine, with the same effect you'd get if you'd used scp or scp -r. I'm just hoping I can do this w/o having to drop out of emacs or even use the eshell (but I'll probably just do that until I get an answer here).

  • In most of the installations I've seen, C-x C-f /user@somehost:/somedir is sufficient since scp is the default exchange method. Try it and see. Maybe you can save a few key bumps. – ephsmith Jul 6 '12 at 5:07
  • That just opens a dired buffer. It doesn't actually copy the dir over like "scp -r user@somehost:/somedir ." would do. – labyrinth Jul 6 '12 at 5:18
  • I'm understanding your question more clearly now. The question title had me thinking you wanted to copy files directly from dired. I use ansi-term for commands like that if I don't want to leave emacs. Emacs was built for customization. I'm sure you'll get an answer with a lisp snippet at some point. – ephsmith Jul 6 '12 at 5:27

Here's one way. This works for me on emacs 23.

In dired mode, navigate to the file you'd like to copy.

  1. Press M to mark the file.
  2. Do an M-x dired-do-copy and you'll be prompted for a location in the mini-buffer.
  3. Edit the location to the local location you'd like to copy to and smack enter.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.