How do I get a list of every folder and file?
On the file server, or a PC with the share mapped, open Windows PowerShell and run one line. Change S:\ to the folder you plan to move.
Get-ChildItem -LiteralPath "S:\" -Recurse -Force | Select-Object FullName | Export-Csv -Path "$env:USERPROFILE\Desktop\folder-list.csv" -NoTypeInformation -Encoding UTF8
- -Force includes hidden and system files, which are left out otherwise.
- -Encoding UTF8 keeps accented letters. Windows PowerShell 5.1 saves CSV as ASCII unless told otherwise.
- -NoTypeInformation drops the “#TYPE” line. The tool skips that line if it is there.
Drop folder-list.csv from your desktop into the tool. A plain text file with one full path per line works too, and so does pasting.
Which limits does it check?
Each path is rebuilt as it will look after the move, then measured:
- SharePoint length = library and folder +
/+ the path below the folder being moved. - Synced length = the synced library folder on a PC + any folder after the library name + the same path.
Folders with no line of their own in the list are checked too.
Then it flags:
- Over 400 in SharePoint. Microsoft’s limit for the entire decoded path, including the file name. Every character counts, including slashes and spaces.
- Over 400 once encoded. Microsoft says spaces and special characters count in their encoded form (a space becomes %20), so these are worth a second look.
- Over 260 when synced. Word, Excel, PowerPoint and File Explorer on Windows can’t open a path longer than 260 characters.
- Blocked characters:
" * : < > ? | - Blocked names: .lock, CON, PRN, AUX, NUL, COM0 to COM9, LPT0 to LPT9, desktop.ini, names starting with
~$, and_vti_anywhere in a name. - “Forms” at the top of a library, and names that start or end with a space.
- # or % in a name, which some organizations don’t support yet.
What should I check before shortening paths?
- Shorten folders near the top first. One shorter client folder name shortens every path below it. The “Where the long paths are” table shows which folders to start with.
- Size the synced folder for the longest user name. The synced path starts with the user’s own folder, so the same file can fit on one PC and fail on another.
- Links to other workbooks. Excel formulas that point at a renamed or moved file stop updating. In Excel, open Data > Queries and Connections > Workbook Links and use Change source after the move.
- Hidden files. desktop.ini and ~$ files are on Microsoft’s blocked list. Leave them out of the move.
Rename on the server before the move, while everyone still knows where things are. Our field guide on moving a file server to SharePoint covers the rest of the plan.
Questions
Is my folder list uploaded anywhere?
No. Your browser reads the file and runs every check on your computer. Close the tab and it is gone.
SharePoint allows 400 characters. Why flag 260?
SharePoint accepts the file, but desktop Word, Excel and PowerPoint on Windows cannot open a path over 260 characters. Syncing adds the synced folder to the front of every path, so files near 260 on the server go over once synced.
Can I check a library that is already in SharePoint?
Yes. Run the same PowerShell line on the synced library folder, set “Folder being moved” to that folder, and set the library field to the library name.
Does it rename anything?
No. It gives you a list of every path with its lengths. You choose the new names, then rename on the server or in SharePoint in the browser.
Sources
- What are the file path length limits?, Microsoft Support,
- Restrictions and limitations in OneDrive and SharePoint, Microsoft Support,
- Get-ChildItem (PowerShell 5.1), Microsoft Learn,
- Export-Csv (PowerShell 5.1), Microsoft Learn,
- Find links (external references) in a workbook, Microsoft Support,
