I'm trying to copy multiple directories with one command. It's kind of a mess since there are spaces in the paths, but I can't quite get it to work.

Imagine a structure like this:

/path/to/some directory1/
/path/to/some directory2/
/path/to/some directory3/

I'm hoping to do something like:

scp -r "/path/to/some\ directory*" user@server:/path/to/destination/

I just can't figure out the syntax for the life of me. Any tips?

Thanks in advance!

  • Oh, and rsync isn't an option.
    – jrronimo
    Jul 17, 2022 at 1:37
  • tar cf - paths | ssh server ‘cd path && tar xf -‘
    – Outtruder
    Jul 3 at 17:43

2 Answers 2


‪Putting the * inside the ""s is preventing your shell from expanding your wildcard (scp does not expand wildcards - that’s the job of your shell). Also, you’re doubling up on escaping the space and quoting it. You only need to do one of the two.

One of the two following options should work‬:

scp -r "/path/to/some directory"* user@server:/path/to/destination/

scp -r /path/to/some\ directory* user@server:/path/to/destination/

I used like this, and ok:

scp -r "/path/to/{directory1,directory2,...}" user@server:/path/to/destination/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .