r/sharepoint • • 4d ago

SharePoint Online SPO file path maximums

We are moving data from shared network drives to SPO, and the subject of what the exact maximum file path can be has come up.

When we were using Sharegate to do test migrations we got lots of errors saying that data couldn't be migrated due to maximum file path being exceeded.

When we ran a PS script to give us the path lengths, we can find LOTS of files with paths of 340+ characters, some 370 chars. That is also not counting the spaces as 3 chars.

The key is that this data will be sync'd to Onedrive, which as I understand it somehow adds the local path name on top of the URL. What I haven't been able to nail down is how much of that is added. For example if I look in Explorer right now, my Onedrive says "C:\users\username\Way Too Long of a Company Name Corporation". Paraphrasing of course, but in reality it's 65 characters long. Some people with longer user names will have an even longer path.

I assume we are going to be (trying to) forcing this department to rename folders and/or files to be shorter names, (please no more sentences), but I need to come up with a number that I can give for the maximum that will be allowed in the path/file name.

What do you think is the maximum path length I should say?

Some of this data may wind up in Teams sites. Does anyone know if that works differently?

Also this isn't even getting into all of the invalid characters that are in these folder/file names. That's a different can of worms.

P.S. Please save any rants about using onedrive to sync this data to laptops. Neither you or I are going to change the company's culture, so don't bother trying.

2 Upvotes

8 comments sorted by

5

u/whatdoido8383 3d ago edited 3d ago

The key is that this data will be sync'd to Onedrive

First off, highly recommend you reevaluate this. If your workflow requires access through Fie Explorer, SharePoint may not be the product for you. It's riddled with issues and is a constant ticket generator for us. We highly discourage it but of course, management pushed everything into SharePoint against our guidance and it's a constant mess.

File paths for Windows must be under 254 characters total for the whole path.

What really sucks is if you exceed that, OneDrive bombs out and shuts down until you fix it. Horrible user experience as now none of their data is in sync with the cloud.

0

u/Scouter_Ted 3d ago

"File paths for Windows must be under 254 characters total for he whole path."

Can you explain this a bit more? We have tens of thousands of files that have paths that are 340+ characters or more. How do they work if the limit is 254?

We had been using Citrix clients, and users would access the data through explorer on those clients, but then we got rid of Citrix, put users on the VPN, and now they are just accessing the data on a mapped file share.

I don't understand how that could work if the Windows limit was 254 characters.

2

u/whatdoido8383 3d ago

OneDrive and SharePoint File Path Limitations

When synchronizing SharePoint Online document libraries to Windows using the OneDrive sync client, file and folder paths must remain within supported character limits.

Although SharePoint Online supports longer paths, Windows File Explorer and some desktop applications have more restrictive limitations. Files that work in SharePoint Online may therefore encounter errors when synchronized locally.

File Path Character Limits

ComponentCharacter Limit
SharePoint Online400 characters
OneDrive Sync Client520 characters
Windows File Explorer260 characters
Microsoft Office Desktop ApplicationsApproximately 256 characters
Individual File or Folder Name255 characters
Recommended Local File Path254 characters or fewer

Recommendation: Keep complete local Windows file paths at or below 254 characters to minimize synchronization and compatibility issues.

How File Paths Are Calculated

The complete local file path includes the drive letter, Windows user profile, synchronization folder, nested folders, and filename.

Example:

C:\Users\Username\Organization\Site - Library\Folder\Subfolder\Document.xlsx

All characters count toward the total, including spaces, backslashes, and file extensions.

Why File Path Errors Occur

Windows traditionally uses a 260-character path limitation known as MAX_PATH.

Although modern Windows versions support longer paths, not all applications support this functionality.

Exceeding supported path limits can result in:

  • OneDrive "File path too long" synchronization errors.
  • Files failing to synchronize.
  • Errors opening, saving, moving, or renaming files.
  • Files working in SharePoint Online but not through Windows File Explorer.

Best Practices

To minimize file path issues:

  • Keep complete local paths at or below 254 characters.
  • Use short, descriptive folder and file names.
  • Avoid deeply nested folder structures.
  • Eliminate unnecessary words or repeated information in filenames.
  • Account for additional characters introduced by local synchronization folder paths.
  • Remember that different Windows usernames and synchronization locations can affect total path lengths.

Summary

A maximum local file path length of 254 characters is recommended for SharePoint document libraries synchronized through OneDrive.

This is a conservative compatibility guideline rather than a strict OneDrive limit. Following it helps reduce synchronization errors and improves compatibility with Windows File Explorer and Microsoft Office.

1

u/Scouter_Ted 3d ago

Not to be annoying about this, but I still don't get this line:

Windows File Explorer260 characters

I can go to one of the files that has a path length of 350 characters, and open that word or excel document with no problems. And that is doing it from a mapped shared drive over a VPN from my house.

That's why we are in this position now. None of the users ever got errors when they were saving these incredibly long file paths. If it would have errored out years ago, (and yes, we have documents going back more than a decade like this), a lot of this problem would have been avoided.

1

u/dr4kun IT Pro 3d ago

Mapped shared drive shows itself as drive Z, and then - is it 350 characters from Z:.........ext?

In Win10 and Win11, it's possible to override this limit by a change in the registry, you may want to check if this was rolled out as a global change in your org or at least on your machine. Otherwise the ~255 characters is a Windows limit, not a SharePoint one (its max path is 400 characters when in browser).

2

u/whatdoido8383 3d ago

Yep, bingo. Even if long file path support is enabled\rolled out, not all applications support it and why the guidance is still <254.

4

u/dr4kun IT Pro 3d ago

Tell them 210-220. It's under 254 characters in total but this needs to include the whole path, from https, to work fine across all scenarios.

This is a data governance issue. Suggest they create more flat structures, with more top-level folders and not go into many levels of nestes folders. Create more sites tied into hubs and more libraries in those sites, tie navigation from home page and navigation tab. Create libraries with short names and no spaces, then rename them - the original name is used for the url. Keep short but self-explanatory urls for sites. Cut down on characters where possible but ultimately the very long folder and files names & multi-nested folders need to go.

Remember that access control should happen at site level, with extra restrictions at libraries if needed, but not at file/folder/subfolder level. Plan security and audiences first, then build a structure that supports that.

3

u/ShareGate_Shaylyn 3d ago

Hey, I work at ShareGate so I can help here.

SharePoint Online's URL limit is 400 characters, which is what our migration errors are flagging. The local OneDrive sync limit is 256 characters for the full local path including the C:\users\username\OneDrive prefix.

For your situation, with a 65 character OneDrive prefix and files at 340-370 characters, you're going to hit the local sync limit even on files that migrate successfully to SharePoint. The safe working maximum to give your department for the SharePoint path is probably around 180-190 characters, which leaves a buffer for the local path.

Our source analysis will flag everything approaching or exceeding the 400 character SharePoint limit. For the flatten folder hierarchy option in the tool, that can help reduce path depth if some of your deep folder structures are the main culprit rather than long file names. And for invalid characters, ShareGate can automatically replace those during migration so that should be covered.