File name too long when copying to a directory with shorter file path

Solution 1:

The fully qualified path of some subdirectory (before or after copying) is too long. This is a limitation of the cmdlet (and to some extent, the API it targets).

Easiest workaround is to use Robocopy: https://technet.microsoft.com/en-us/library/cc733145.aspx

Solution 2:

You can use the robocopy command, but I found the easier (though a bit slower) method is to just zip the folder, copy the zip, and unzip it. Alternatively you can move the heavily nested folder up to a higher-level directory, copy it over, and then move it back to it's nested location.

Not sure why this works, but according to this article windows has a max length for file name, but for some reason checks the length of the entire file path when copying.

So the reason your file path was able to get so long in the first place was if it was created manually, instead of copied over. Or if it was created from a program, or any other method that doesn't involve copying. At least that's my guess