When you run a SharePoint Migration Tool migration, some files may be skipped with a “path too long” error. This happens because Windows and SharePoint have a 400-character limit for the full file path including the file name. If any file exceeds this limit, the SharePoint Migration Tool will skip it and log it as a failure. This article explains why long path files are skipped, how to identify them before migration, and the exact steps to fix the paths so all files transfer successfully.
Key Takeaways: How to Fix Long Path Files in SharePoint Migration
- SharePoint Migration Tool > Scan report: Review the scan report before starting the migration to see which files exceed the path length limit.
- Windows 10/11 Enable Long Paths: Enabling long path support in Windows Group Policy does not change SharePoint’s 400-character limit.
- Shorten folder names or restructure: The only reliable fix is to rename deep folders or move files to a shallower folder structure.
Why the SharePoint Migration Tool Skips Long Path Files
The SharePoint Migration Tool uses the SharePoint REST API, which enforces a maximum URL length of 400 characters for the document library path and file name combined. This limit applies to the full URL path after the site collection URL. For example, if your site URL is https://contoso.sharepoint.com/sites/marketing, the remaining path for the document library and file cannot exceed 400 characters.
When you migrate files from a local file server or network share, the tool maps the local folder structure to the SharePoint document library. If any local folder path plus file name exceeds 400 characters, the tool flags the file as “path too long” and skips it. The tool does not automatically truncate or rename paths. You must fix this before or during the migration.
What Counts Toward the 400-Character Limit
The 400-character limit includes:
- The document library name (for example,
Shared Documents) - All folder names in the path
- The file name including the extension
- Spaces and special characters (each counts as one character)
The site collection URL and the /sites/ portion are not included in this count. Only the path starting from the document library root is measured.
Steps to Identify and Fix Long Path Files Before Migration
- Run a scan with the SharePoint Migration Tool
Open the SharePoint Migration Tool from the Microsoft 365 admin center or download the desktop version. Create a new migration job and select your source folder. Before clicking Migrate, click Scan. The tool generates a report that lists all files that will be skipped due to long paths. - Review the scan report
Open the scan report in your browser. Look for the Issues tab. Files with a path longer than 400 characters appear with the error codePathTooLong. Note the full local path of each file. You can export the report to CSV for easier analysis. - Shorten folder names in the source location
Rename deep folders to shorter names. For example, rename2025-Q1-Campaigns-Q1-2025-Final-Revisionsto2025-Q1-Final. This reduces the total path length. Do this on the source file server before running the migration again. - Restructure the folder hierarchy
If shortening folder names is not enough, move files from deep subfolders to a higher level. For example, instead ofProjects > ClientA > 2025 > Deliverables > Final, useClientA-2025-Finalas a single folder name. This reduces the number of path segments. - Use the SharePoint Migration Tool with the SkipLongPaths option
If you cannot fix all long paths manually, you can configure the tool to skip them automatically. In the tool’s settings, enable Skip files with path longer than 400 characters. The tool will then skip those files and continue the migration without stopping. You will need to migrate skipped files separately after fixing their paths. - Run the migration again
After renaming folders or restructuring, run the scan again to confirm no files exceed the limit. Then start the migration. The tool will upload all files that now have valid paths.
If SharePoint Migration Tool Still Skips Files After Fixing Paths
Files with special characters in the path
The SharePoint Migration Tool may also skip files if the path contains characters that SharePoint does not allow. These include ~ # % & { } \ : < > ? | ". Check the scan report for error code InvalidFileName. Rename the file or folder to remove these characters.
File names that end with a space or period
Windows allows file names to end with a space or period, but SharePoint does not. The migration tool will skip these files with error code InvalidFileName. Rename the file to remove the trailing space or period before running the migration again.
Network path vs local path
If you are migrating from a network share, the path length includes the full UNC path like \\server\share\folder\file.docx. This path is typically longer than the local drive path. Consider mapping the network share to a drive letter like Z:\folder\file.docx. This reduces the path length for the scan. However, the SharePoint path limit still applies after mapping.
| Item | Local Drive Path | Network Share Path |
|---|---|---|
| Example path | C:\Data\Projects\File.docx | \\fileserver\share\Projects\File.docx |
| Character count | Approximately 25 characters | Approximately 40 characters |
| Risk of exceeding limit | Lower | Higher |
After you fix all long path files and rerun the migration, all files should transfer successfully. The SharePoint Migration Tool logs each file's status in the migration history. You can verify that no files were skipped by checking the Completed tab in the tool after the job finishes.
For future migrations, plan your folder structure to keep paths under 400 characters. Use short folder names and avoid nesting folders more than five levels deep. This prevents path length issues from the start.