When migrating to OneDrive, the path length limitation is a common issue.

OneDrive has several limitations: A given element (file or folder) cannot be more than128 characters.

A total file path including full path + file name cannot be more than 260 characters.

All characters have to be URL encoded, so many characters count as 3 characters. So instead of assuming that you can use 128 characters for a file name, consider limiting your document name to around 40-60 characters!



Technical discussion from BitTitan (Don't read this unless you are into the technical stuff!) (https://help.bittitan.com/hc/en-us/articles/115008259028-Why-am-I-getting-Path-Too-Long-errors-when-migrating-to-OneDrive-)


Why am I getting Path Too Long errors when migrating to OneDrive?

Ans​wer:

When migrating to OneDrive, the path length limitation is a common issue. OneDrive has several limitations:

  • A given element (file or folder) cannot be more than 128 characters.
  • A total file path including full path + file name cannot be more than 260 characters.
  • All of them have to be URL encoded, so many characters count as 3 characters, so the limit can be reached faster that we first expect.

It is, however, not always clear why the errors arise when the path actually seems small. So let’s assume the following environment:

One would assume that the file is/folder/this & that.docx, 24 characters.

However, when using the API, we have to use the complete OneDrive path, which is this case would be:

/personal/test_user_domain_com/Documents/folder/this & that.docx

This is 64 characters.

We also have to URL encode this string:

%2Fpersonal%2Ftest_user_domain_com%2FDocuments%2Ffolder%2Fthis%20%26%20that.docx

We're already at 80 characters out of the 260-character limit.

When applying file permissions, we need to use the full file path to the file, which is even longer:

https://domain-my.sharepoint.com/personal/test_user_domain_com/Documents/folder/this & that.docx

Then we URL encode this, ending up with the following:

https://domain-my.sharepoint.com%2Fpersonal%2Ftest_user_domain_com%2FDocuments%2Ffolder%2Fthis%20%26%20that.docx

This is 112 characters, when the file appears to be only 24 characters.