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.

2 Answers 2

2

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.

3
  • Yep. If you're having file path issues with robocopy, it's likely due to the commands returning $source and $destination failing.
    – Cpt.Whale
    Commented Feb 23, 2020 at 0:44
  • Thanks Danfossi, will check by adding /256. Commented Feb 23, 2020 at 14:42
  • 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. Commented Feb 23, 2020 at 14:49
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
1
  • Thanks for the information...i will try the hack Commented Feb 23, 2020 at 15:01

You must log in to answer this question.

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