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.
If you want a directory \\172.16.254.41\c$\temp\foo
you have to ask for one:
robocopy /e foo \\172.16.254.41\c$\temp\foo