4

I'm writing on a batch file to copy a certain file to a samba-share.

I've already read robocopy transfer file and not folder and thought I would be good using

robocopy "E:\Some\Path\with spaces" "\\sambaServer\some\path\with spaces" "myFile.rar" /z /MIR

But I keep seeing

Source: E:\Some\Path\with spaces\
Destination: \\sambaServer\Some\path\with spaces" myFile.rar \Z \MIR\

Files: *.*

And ofcourse I get an error

ERROR 123 (0x0000007B) Accessing Destination folder \\sambaServer\Some\path\with spaces" myFile.rar \Z \MIR\ The syntax for file name, folder name or the volume label is incorrect.

So apparently robocopy takes the whole second part - the destination folder, the file and the parameters - together as the destination folder.

Why is this not working? What am I doing wrong?


It worked when I copy the whole folder instead using

robocopy "E:\Some\Path\with spaces" "\\sambaServer\some\path\with spaces" /z /MIR
derHugo
  • 143
  • 1
  • 1
  • 7

2 Answers2

1

Huh, I'm not sure, but it looks like it can be permissions issue, see here http://blogs.technet.com/filecab/archive/2008/07/31/robocopy-mir-switch-mirroring-file-permissions.aspx

For me robocopy works fine:

robocopy "D:\test" "\share-name\folder-name\test test" "11.rar" /z /MIR

mirh
  • 167
  • 7
Johnyd
  • 172
  • 4
  • 1
    Thanks, it turned out that it was a mix of permissions and `/MIR` ... my mistake: I only copy 1 file but `/MIR` attempts to anyway mirror the whole folder tree to the server, but I had only the permission to copy that one file to that specific location. So leaving the `/MIR` out works for me now – derHugo Feb 02 '18 at 07:44
0

Please note that there is a defect in ROBOCOPY, which fails if a single file is specified even though the documentation indicates that should be valid. Just add a wildcard (*) to the end of the filename and it will be copied. (Of course, if the wildcard hits more than one file, all hit files will be copied, so this is not an ideal circumvention of the defect. )

Ferdie documented this circumvention back in 2016 at https://minglemangleofmymind.wordpress.com/2014/11/21/robocopy-error-2-accessing-destination-directory-and-the-system-cannot-find-the-file-specified/

By the way, I don't have enough reputation points to post the same circumvention at robocopy transfer file and not folder