issue with robocopy on copying files from source to destination of longpath

3

I am using robocopy $source $destination /MIR, the thing is it does copy files in sync with the source but skippnig the files and directories from source which are having long path names.

i would like to have a fix for this, i have tried several ways but it did not worked out.

E PSVP LIFE

Posted 2020-02-22T05:20:54.463

Reputation: 31

Answers

1

Robocopy have no limit on long paths by default, you can optionally disable it with "/256" flag,

Eg:

robocopy $source $destination /MIR /256

Ref: StackOverFlow

Solution 2: Another solution to bypass this type of error is to mount the destination folder one level lower and resume synchronization from there.

Danfossi

Posted 2020-02-22T05:20:54.463

Reputation: 67

Yep. If you're having file path issues with robocopy, it's likely due to the commands returning $source and $destination failing. – user19702 – 2020-02-23T00:44:02.080

Thanks Danfossi, will check by adding /256. – E PSVP LIFE – 2020-02-23T14:42:20.250

One more thing is whether there is any possibility of data loss such as deletion of files or folder directories from source,i tried copying files and directories from source to destination from robocopy.I am using to copy files from D:\ drive to external disc drive (My Book device) as i see some files were missed while executing the command previously don't know exactly that this code execution has caused some issue on deletion. – E PSVP LIFE – 2020-02-23T14:49:14.957

0

Double-check that all the file paths actually make it into $source and $dest. The windows API really dislikes long filepaths.

One solution for this type of problem is to use Unicode paths, which look like \\?\C:\path\to\file or \\?\UNC\server\share and allow 30,000 characters. A hacky way to do this without knowing earlier parts of your script is just editing the strings of your source paths:

robocopy ($source -replace '\\','\\?\') $dest /MIR

or

robocopy ($source -replace 'C:','\\?\C:') $dest /MIR

user19702

Posted 2020-02-22T05:20:54.463

Reputation: 361

Thanks for the information...i will try the hack – E PSVP LIFE – 2020-02-23T15:01:59.070