How to fix invalid file names in OneDrive
OneDrive and SharePoint skip any file or folder whose name breaks their naming rules. Learn the rules, find the affected items and rename them without breaking links.
The problem
OneDrive does not upload an item whose name it considers invalid. The item stays on your computer, OneDrive marks it with a sync error, and everything else keeps syncing around it. In a large folder tree, a handful of these items is easy to miss until someone on another device cannot find a file.
The rules are the same for OneDrive and SharePoint, because OneDrive for work or school stores files in SharePoint. They cover specific characters, a short list of reserved names and leading or trailing spaces.
Names OneDrive and SharePoint do not accept
| Rule | Examples | Notes |
|---|---|---|
| Unsupported characters | " * : < > ? / \ | | Not allowed anywhere in a file or folder name. |
| Leading or trailing spaces | " Budget.xlsx", "Invoices " | The space is often invisible in File Explorer. |
| Reserved names | .lock, CON, PRN, AUX, NUL, COM0–COM9, LPT0–LPT9, desktop.ini | Blocked as complete names. |
| Names starting with ~$ | ~$Report.docx | Office creates these as temporary lock files while a document is open. |
| _vti_ anywhere in a name | old_vti_files | Reserved by SharePoint. |
| "forms" at the root of a library | forms | SharePoint only; allowed inside sub-folders. |
Some organizations have not enabled # and % in names yet. Office 2010 does not support &, and Office desktop apps cannot save into a folder whose name contains a semicolon.
Symptoms
- A red error icon appears on the file or folder in File Explorer.
- The OneDrive activity center lists the item as unable to sync.
- The file is present on your computer but missing on OneDrive.com and on your other devices.
- A synced SharePoint library shows the item locally while colleagues cannot see it.
Causes
Files created on other systems
Windows itself blocks most of these characters, so on a Windows PC they usually arrive from macOS, Linux, mobile devices, network storage or archive files, where they are allowed.
Accidental spaces
A space typed at the end of a folder name, or copied from an email or a spreadsheet, makes the whole folder invalid for sync.
Migrations from file servers
Moving years of content from a network share into OneDrive or SharePoint exposes names that were acceptable on the old server.
Office lock files
Files starting with ~$ appear while a document is open. They are expected and disappear when the document is closed; they do not need renaming.
How to fix it
-
See which items OneDrive reports
Select the OneDrive cloud icon in the notification area of the taskbar. The activity center lists items that could not sync. Note the folder each one is in.
-
Search the whole folder for invalid names
For large folders, list every affected item at once. This PowerShell command only reads names; it does not change anything. Use $env:OneDriveCommercial instead of $env:OneDrive for a work or school account.
$root = $env:OneDrive Get-ChildItem -LiteralPath $root -Recurse -Force -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '[\\/:*?"<>|]' -or $_.Name -match '^\s|\s$' -or $_.Name -match '_vti_' -or $_.BaseName -match '^(CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])$' } | Select-Object FullName -
Pause syncing before renaming many items
Select the OneDrive icon, open Settings, and choose Pause syncing. Renaming while paused avoids OneDrive processing every change as it happens.
-
Rename each item
Select the item in File Explorer, press F2 and type a valid name. Replace unsupported characters with a hyphen or remove them, and delete leading or trailing spaces. Use the same replacement everywhere so names stay predictable.
-
Leave system and lock files alone
Do not rename ~$ files or desktop.ini. Close the Office document to clear its lock file. desktop.ini is a Windows system file that does not normally sync.
-
Resume syncing and confirm
Resume syncing from the OneDrive menu. The error icons should clear as each renamed item uploads. Check OneDrive.com to confirm the files are present.
Before you change anything
- Renaming a folder changes the path of everything inside it. Shortcuts, shared links and formulas that point to files in that folder can stop working.
- Two different names can become identical after you replace characters. OneDrive then treats them as a conflict, so check for duplicates before renaming in bulk.
- Back up important folders before bulk changes, and try your renaming approach on a copy first.
When OneDriveSyncFixer helps
Microsoft documentation
- Restrictions and limitations in OneDrive and SharePoint (opens in a new tab)support.microsoft.com
- Fix OneDrive sync problems (opens in a new tab)support.microsoft.com
This guide summarizes Microsoft’s published guidance in our own words. Microsoft documentation remains the authoritative source.
Related guides
Keep troubleshooting
-
Characters you can’t use in OneDrive and SharePoint file names
The exact characters OneDrive and SharePoint reject, the special cases for #, %, & and the semicolon, and how to replace them consistently.
-
SharePoint file path too long: limits, causes and fixes
SharePoint and OneDrive allow paths up to 400 characters, but Windows apps often stop at 260. See which limit applies, how to measure a path and how to shorten it.
-
OneDrive not syncing on Windows: a step-by-step checklist
Work through the usual reasons OneDrive stops syncing, in order: sign-in, paused sync, storage, problem files, app version and finally a reset.