When a file name or the full path to a file exceeds Windows or OneDrive character limits, the file fails to sync and blocks the entire library. This issue commonly stops new files from uploading, prevents edits from saving, and displays an error in the OneDrive sync status. The root cause is that OneDrive for Business enforces a 400-character limit for the full file path including the file name. This article explains why this limit exists and provides three methods to locate and rename or move the blocking files.
Key Takeaways: Fixing Files That Exceed the Path Length Limit
- OneDrive sync status icon > error message: Hover over the red circle with a white X to see the exact error about file name or path length.
- File Explorer > OneDrive folder > path column: Sort files by full path to identify the file that exceeds 400 characters.
- PowerShell command Get-ChildItem: Use a one-line script to list all files with a path longer than 400 characters in your OneDrive folder.
Why OneDrive Blocks Files With Long Paths
OneDrive for Business uses the NTFS file system on Windows, which has a maximum path length of 32,767 characters for applications that enable long path support. However, OneDrive itself enforces a stricter limit of 400 characters for the full path including the file name. This limit applies to the combined length of the drive letter, folder structure, and file name. When any file or folder in a synced library exceeds this limit, OneDrive stops syncing that file and any files in the same folder hierarchy. The library then shows an error state, and users cannot upload, edit, or delete files until the blocking file is addressed. The limit exists to maintain performance during sync operations and to avoid issues when files are accessed on other platforms or through SharePoint Online, which also enforces a 400-character limit for URLs.
How the 400-Character Limit Is Calculated
The 400-character limit includes the local folder path on your computer plus the file name. For example, if your OneDrive folder is located at C:\Users\YourName\OneDrive – Contoso, that prefix is 38 characters. A folder structure under that path like Projects\2025\Q1\Client Deliverables adds another 40 characters. If the file name itself is 330 characters, the total exceeds 400 and the file will not sync. SharePoint Online has a similar limit of 400 characters for the URL path. This means files that sync from SharePoint to OneDrive are also subject to this restriction.
Steps to Find and Fix the Blocking File
The following methods help you locate the file with the long path and then rename or move it so OneDrive can resume syncing.
Method 1: Use the OneDrive Error Message
- Open OneDrive sync status
Click the OneDrive cloud icon in the system tray near the clock. If you see a red circle with a white X, hover over it. A pop-up message displays the file name and the error: “The file name is too long” or “The path is too long.” - Note the full file path
The error message shows the relative path from your OneDrive root. Write down the folder and file name exactly as shown. This is the file that blocks the library. - Navigate to the file in File Explorer
Open File Explorer and go to your OneDrive folder. Use the path from the error message to locate the file. If the folder path is long, you may need to expand each subfolder manually. - Rename or move the file
Right-click the file and select Rename. Shorten the file name to under 100 characters. Alternatively, move the file to a higher-level folder to reduce the path length. After the change, OneDrive resumes syncing within a few seconds.
Method 2: Sort Files by Path Length in File Explorer
- Open your OneDrive folder
Press Windows key + E to open File Explorer. Navigate to your OneDrive folder location, typically C:\Users\YourName\OneDrive – CompanyName. - Add the Path column
Right-click any column header like Name or Date modified. Click More. In the Choose Details dialog, scroll down, check the box for Path, and click OK. The Path column now shows the full path for each file. - Sort by Path length
Click the Path column header to sort files alphabetically by path. Files in deeper folders appear near the bottom. Manually scan for files with very long paths. A path longer than 400 characters will appear as a very long string in the Path column. - Rename or move the identified files
For each file with an excessively long path, right-click and select Rename. Shorten the name to under 50 characters. If multiple files share a long folder path, consider moving the entire folder to a higher level in the OneDrive structure.
Method 3: Use PowerShell to List Long Path Files
- Open PowerShell as administrator
Press Windows key, type PowerShell, right-click Windows PowerShell, and select Run as administrator. Click Yes in the User Account Control prompt. - Run the Get-ChildItem command
Type the following command and press Enter:Get-ChildItem -Path "C:\Users\YourName\OneDrive - CompanyName" -Recurse | Where-Object { $_.FullName.Length -gt 400 } | Select-Object FullName
Replace the path with your actual OneDrive folder location. This command lists every file whose full path exceeds 400 characters. - Review the output
The PowerShell window displays the full path of each file that exceeds the limit. Copy each path to Notepad for reference. - Rename or move each file
For each file in the list, navigate to its location in File Explorer. Shorten the file name or move the file to a shallower folder. After making changes, run the PowerShell command again to confirm no files remain over 400 characters.
If OneDrive Still Shows an Error After the Main Fix
After renaming or moving the blocking file, OneDrive may still display an error. The following scenarios explain why and how to resolve them.
OneDrive Shows a Red X on the Folder Icon
A red X on a folder instead of a file means the folder name itself is too long. The combined path of the folder hierarchy exceeds 400 characters even before adding any file names. To fix this, rename the folder to a shorter name or move it to a higher level in the OneDrive structure. For example, change “2025 Marketing Campaign Q1 Drafts Final Review” to “2025-Marketing-Q1”. After renaming the folder, all files inside it will sync normally.
OneDrive Stops Syncing the Entire Library
If OneDrive stops syncing the entire library after you fix one file, a second file with a long path may exist deeper in the folder structure. Run the PowerShell command from Method 3 again to check for additional files. Repeat the rename or move steps for each file until the command returns no results. After the last file is fixed, OneDrive resumes syncing the whole library.
OneDrive Error Message Says the File Name Contains Invalid Characters
Some files with long names also contain characters that Windows or SharePoint does not allow, such as “, :, /, \, |, <, >, or ?. If the error message mentions invalid characters in addition to the length, rename the file to remove those characters. Use only letters, numbers, spaces, hyphens, underscores, and periods. After removing the invalid characters, the file syncs as long as the total path is under 400 characters.
| Item | OneDrive for Business | SharePoint Online |
|---|---|---|
| Maximum path length | 400 characters | 400 characters |
| Maximum file name length | 255 characters | 255 characters |
| Invalid characters in file name | ~ # % & : < > ? / \ { | } | ~ # % & : < > ? / \ { | } |
| Sync behavior when limit exceeded | File not uploaded; error shown in sync status | File not uploaded; error shown in library |
| Fix method | Rename or move file locally; change syncs automatically | Rename or move file in browser; change syncs to OneDrive |
After you rename or move the blocking file, OneDrive automatically resumes syncing the entire library. To prevent this error in the future, set a naming convention that keeps file names under 100 characters and limits folder depth to five levels. If your team frequently works with deep folder structures, use the PowerShell command as a weekly check to catch long paths before they block the library.