๐ Recipe ยท SharePoint & OneDrive
Scan Synology NAS for File Paths Exceeding SharePoint Migration Limits
Identify files with paths longer than 400 characters on a Synology NAS before migrating to SharePoint Online or OneDrive
Complexity
Intermediate
Impact
migration-prep + data-audit + sharepoint + onedrive + file-server
Context
Why This Matters
SharePoint Online and OneDrive enforce a 400-character limit on the total decoded URL path of any file, including the site address, library name, folder hierarchy, and filename. Files that exceed this limit will fail to migrate or sync, often silently, leaving gaps in the destination tenant.
When migrating data from a Synology NAS (or any on-prem file server) to SharePoint/OneDrive, the source paths may look short on the NAS โ for example /volume1/Marketing/Campaigns/... โ but once the destination site URL (e.g. https://contoso.sharepoint.com/sites/Marketing/Shared Documents/) is prepended, the effective path can easily blow past 400 characters.
This recipe gives you two reliable ways to pre-flight your data: run a native Bash command over SSH directly on the Synology (fastest, avoids Windows' legacy 260-character path ceiling), or run a PowerShell script from a Windows workstation with the share mapped. Run this before kicking off any migration tool (Mover, ShareGate, Migration Manager) so you can remediate the offending paths up front.
Expected Outcomes
After completing this recipe you will have:
- A CSV or text report listing every file whose absolute path exceeds the character threshold you specify.
- The exact character count for each offending path, so you know how many characters need to be trimmed.
- A remediation worklist that can be handed to data owners for renaming, re-foldering, or archival decisions.
- Confidence that your SharePoint/OneDrive migration batch will not hit silent path-length failures.
Risks & Considerations
Things to watch out for
- Use the NAS-native approach when possible. Running the scan from Windows against a deeply nested share can itself fail because Windows' legacy Win32 API caps paths at 260 characters โ the very files you are hunting may be invisible to
Get-ChildItem. Bash over SSH on the Synology has no such limit. - Account for the destination URL prefix. Your Synology path does not yet include
https://tenant.sharepoint.com/sites/<SiteName>/<Library>/. That prefix is typically 60โ100+ characters. Scan at a lower threshold (e.g. 300โ350 characters) to leave headroom. - URL encoding inflates length. Spaces become
%20, ampersands become%26, and so on. A path full of spaces and special characters can grow 10โ20% longer once encoded. Err on the side of caution. - Illegal characters are a separate problem. SharePoint blocks
",*,:,<,>,?,/,\,|, and leading/trailing whitespace or periods. Path length is only one dimension โ audit for these too. - Write output to a known share. Do not write the report file inside the folder you are scanning if the folder tree is huge, or you will pollute your own results on re-runs.
- SSH access is privileged. Only the
administratorsgroup on DSM can SSH in. Disable SSH again after you finish if it is not normally on.
Required Permissions
| Permission | Why It's Needed |
|---|---|
| Synology DSM administrator account | Required to enable SSH and read across all shared folders regardless of ACLs. |
| SSH service enabled on DSM | Needed to run shell commands directly on the NAS (Control Panel > Terminal & SNMP). |
| Read access to target shares (Windows method) | The account running PowerShell must be able to traverse every folder under the mapped drive or UNC path. |
| PowerShell 5.1 or PowerShell 7+ (Windows method) | Get-ChildItem in modern PowerShell handles long paths better than older shells, especially with the LiteralPath parameter. |
The fastest way to get this done โ just ask Dex. Copy the prompt below and paste it into your Dex conversation.
For IT Admins
Paste into Dex CoAdmin