简体   繁体   中英

robocopy or xcopy: copy directory and files

I want to use either robocopy or xcopy to copy a directory and its contents to a remote share.

I have attempted this:

xcopy /E /V /C /I /H /Y "foo" \\172.16.254.41\c$\temp
foo\file.sql foo\file2.cmd
2 File(s) copied

This doesn't copy foo directory, though.

This will copy files and directories from the remote path to a local path:

robocopy \\172.16.254.41\c$\temp bar /E

But reversing it doesn't make a difference:

robocopy foo \\172.16.254.41\c$\temp /E

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         1         0         0         0         0         2
   Files :         2         2         0         0         0         3
   Bytes :     2.0 k     2.0 k         0         0         0     1.2 k
   Times :   0:00:00   0:00:00                       0:00:00   0:00:00

As you see, the directory foo was not copied over.

So what can be done to copy local directories+files to a remote path?

---edit---

with robocopy foo \\\\172.16.254.41\\c$\\temp /copyall /E

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         1         0         0         0         0         2
   Files :         2         2         0         0         0         3
   Bytes :     2.0 k     2.0 k         0         0         0     1.2 k
   Times :   0:00:00   0:00:00                       0:00:00   0:00:00


   Speed :               67419 Bytes/sec.
   Speed :               3.857 MegaBytes/min.
   Ended : Tuesday, September 20, 2016 10:25:27 PM

---edit2---

robocopy "C:\directory here\foo" \\172.16.254.41\c$\temp /copyall /e

Results in the same: contents of foo copied to temp on destination, but not the foo directory itself.

---edit3---

robocopy "C:\directory here" \\172.16.254.41\c$\temp /copyall /E

This will copy all contents and directories (including foo) inside "directory here", but I can't do that for this. foo contains just two files, but I need the directory. I must be doing something wrong with robocopy.

如果您想要目录\\\\172.16.254.41\\c$\\temp\\foo ,则必须输入以下目录:

robocopy /e foo \\172.16.254.41\c$\temp\foo

You need to add /copyall snippet to robocopy

robocopy full_path_to_your_foo_folder \\172.16.254.41\c$\temp /copyall /e

I assume that \\172.16.254.41\\c$\\temp is your destination folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM