OneDrive Duplicate Files Created
Resolution Checklist
- 1 Understand why OneDrive creates duplicate files
- 2 Deconflict Office application sync settings
- 3 Clear credential cache and reset on Windows
- 4 Clear keychain credentials and reset on macOS
- 5 Safely merge and clean up duplicate files
- 6 Summary Checklist
OneDrive Duplicate Files Created
When OneDrive detects a conflict between a local edit and a cloud edit that cannot be merged automatically, it preserves both files. It does this by creating a duplicate file and appending your computer’s network name to the filename (for example, Budget-Desktop-PC.xlsx or Document-MacBook.docx).
This manual details how to prevent duplicate file creation by repairing cached credentials and resolving application conflicts on Windows and macOS.
Understand why OneDrive creates duplicate files
Duplicates are typically generated under the following conditions:
- Simultaneous Offline Edits: A file is modified on two devices while offline, and both sync their changes at the same time.
- Corrupted Credential Cache: The sync engine loses validation to modify the cloud file, leading it to save the local edits as a separate version rather than overwriting.
- Office Collaboration (Co-authoring) Failures: Microsoft Office’s upload cache conflicts with OneDrive’s background sync engine.
- Incorrect System Clock: A mismatch of more than 5 minutes between your computer’s system time and the cloud server’s time triggers clock-based sync collisions.
Deconflict Office application sync settings
Microsoft Office has an independent sync component that co-authors documents. If this conflicts with OneDrive:
- Open OneDrive Settings (click the cloud icon, select the Gear Icon, and choose Settings).
- Go to the Sync and backup or Office tab.
- Locate the setting “Use Office applications to sync Office files that I open” (or “File collaboration”).
- Toggle this setting OFF. This tells OneDrive to handle all file syncing directly rather than handing off Office files to the MS Office Upload Center.
Clear credential cache and reset on Windows
Stale OneDrive credentials in the Windows Credential Manager frequently trigger duplicate files.
1. Close OneDrive
taskkill /f /im OneDrive.exe
2. Purge Office and OneDrive Credentials
Open an elevated Command Prompt or PowerShell and remove the cached tokens:
cmdkey /list | findstr /i "OneDrive"
To programmatically clean all Microsoft Office and OneDrive credentials from the vault, execute:
powershell -Command "Get-Credential | Out-Null"
Or manually clear them:
- Open the Start Menu, type Credential Manager, and press Enter.
- Select Windows Credentials.
- Under Generic Credentials, find entries containing
MicrosoftOffice16_Data:ADALorOneDrive Cached Credential. - Click Remove on each entry.
3. Clear Office File Cache
Corrupt Office caches cause constant conflict saves. Delete the cache directory:
rmdir /s /q "%localappdata%\Microsoft\Office\16.0\OfficeFileCache"
4. Reset and Restart OneDrive
%localappdata%\Microsoft\OneDrive\onedrive.exe /reset
Clear keychain credentials and reset on macOS
On macOS, security credentials are saved in Apple’s Keychain, and Office caches are located inside sandboxed containers.
1. Remove Cached Credentials from Keychain
Open Terminal and run the security tool to remove cached OneDrive passwords:
security delete-generic-password -s "OneDrive Cached Credential" 2>/dev/null
security delete-generic-password -l "Microsoft Office Identities Settings 2" 2>/dev/null
2. Clear Office Sandbox Caches
Purge cached OneDrive database caches within Office container dirs:
rm -rf ~/Library/Containers/com.microsoft.SharePoint-mac
rm -rf ~/Library/Group\ Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg
3. Run the Standalone OneDrive Reset Command
/Applications/OneDrive.app/Contents/Resources/ResetOneDriveAppStandalone.command
Safely merge and clean up duplicate files
Once the sync engines are reset, you need to clean up the existing duplicate files:
- Verify the Master File: Open the web portal of OneDrive to verify which file version contains the latest edits.
- Merge Offline Changes: Manually copy any unique edits from the machine-appended file (
-PCName.ext) to the master file. - Delete Duplicates via PowerShell/Terminal:
- Windows (PowerShell command to search and delete files containing
-PCNamein your OneDrive directory):Get-ChildItem -Path "$env:USERPROFILE\OneDrive" -Recurse -Filter "*-*" | Where-Object { $_.Name -like "*$env:COMPUTERNAME*" } | Remove-Item -Force - macOS (Terminal command to find and list duplicate names):
find ~/Library/CloudStorage/OneDrive-Personal -name "*-$(hostname)*" -type f -delete
- Windows (PowerShell command to search and delete files containing
Summary Checklist
| Action Item | Verification Method | Status |
|---|---|---|
| Disable Collaboration | Toggle off File collaboration / Use Office applications in OneDrive | [ ] |
| Clear Windows Vault | Remove all OneDrive and Office keys from Credential Manager | [ ] |
| Clear Mac Keychain | Run security delete-generic-password for OneDrive credentials | [ ] |
| Flush Office Cache | Delete OfficeFileCache (Windows) or container caches (macOS) | [ ] |
| Reset Sync Engine | Perform /reset to establish a new sync state | [ ] |
| Prune Duplicates | Execute script filters to delete files containing hostname suffixes | [ ] |