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

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.

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.

• Yep. If you're having file path issues with robocopy, it's likely due to the commands returning $source and $destination failing. – user19702 Feb 23 at 0:44
• Thanks Danfossi, will check by adding /256. – E PSVP LIFE Feb 23 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. – E PSVP LIFE Feb 23 at 14:49

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

• Thanks for the information...i will try the hack – E PSVP LIFE Feb 23 at 15:01