In SharePoint and OneDrive, there is a limitation on the total number of characters in a folder path + file name. Specifically, the entire path must contain fewer than 400 characters. If you exceed that limit, you'll receive an error message. See this Microsoft article for more information.
It’s important to understand that the definition of ‘characters’ in this case includes more than the characters you can see and read in the folder path, it’s the encoded characters that generate the readable folder path and file name. It takes three encoded characters to generate spaces and most of the special characters (forward slashes, periods, underscores, etc.) found in many readable folder paths, which means the total number of characters can quickly add up.
Here’s a snippet from a SharePoint file path +folder name compared to its URL, to illustrate:
Readable URL (134 characters)
id=/sites/departments/is/Weekly RelayNotes/CY19/IS_weeklyrelaynotes10242019.pdf&parent=/sites/departments/is/Weekly Relay Notes/CY19
Actual URL (168 characters)
Avoid the character limitation and ensure the file is accessible to everyone:
- Reduce the number of characters in folder and file names
- Avoid the storage of files within multiple layers of folders
Excel-specific complication [More info]
In addition to the limitation outlined above there’s another one, specific to the Microsoft Excel desktop application. (Excel Online is unaffected.) The Excel desktop app has a 218-character file path length limitation. If the path to the file (including the file name) exceeds 218 characters, then attempting to save or open a file will result in an error message.
So, opening an Excel file stored in SharePoint while using the traditional Excel application could prove problematic.
Microsoft suggests making sure that the path to the file contains fewer than 219 characters. To do this, use one of the following methods:
- Rename the file so that it has a shorter name.
- Rename one or more folders that contain the file so that they have shorter names.
- Move the file to a folder with a shorter path name.