sharepoint

SharePoint Duplicate Files

Resolution Checklist

  • 1 Understand SharePoint Duplicate Files
  • 2 Resolve Windows Sync Conflict Duplicates
  • 3 Resolve macOS Sync Conflict Duplicates
  • 4 Prevent Future Duplicate File Creation
  • 5 Summary Checklist for SharePoint Duplicate Files

SharePoint Duplicate Files

You may find duplicate files in synced SharePoint libraries with the computer name appended to the filename (e.g., Document-DESKTOP-PC10.docx or Budget-Copy.xlsx). This happens when the OneDrive sync engine detects a conflict between the local copy and the cloud copy.

This guide explains why duplicate files are created and provides terminal-based steps to clean them up on Windows and macOS, along with settings adjustments to prevent future occurrences.


1. Understand SharePoint Duplicate Files

Duplicate files with computer names or the word “Copy” appended to them are created due to sync conflicts:

  • Simultaneous Offline Edits: If two users edit the same file while offline, or if a user edits a file locally while another edits it via the web, the sync client cannot merge the changes. To prevent data loss, it syncs the server version and renames the local version by appending the PC/user name.
  • Sync Database Corruption: If the local OneDrive sync engine database becomes corrupted, it fails to track file metadata states. The client treats the local files as untracked new items and uploads them, causing duplicates.
  • Office Cache Mismatches: When Microsoft Office Upload Center and OneDrive conflict on who manages the sync, they may write parallel copies of the same document.
  • Credential Expiration: If authentication expires during an editing session, the sync client fails to save revisions to the original file, saving it as a duplicate once re-authenticated.

2. Resolve Windows Sync Conflict Duplicates

If your Windows sync client has created numerous duplicate files, you can identify, delete, or merge them, and reset the sync engine database.

Step 1: Force Close OneDrive and Office Apps

Run this command block in Command Prompt to prevent files from being locked while we clean up:

taskkill /f /im OneDrive.exe /im winword.exe /im excel.exe /im powerpnt.exe

Step 2: Scan for and Clean Duplicate Files

Identify files containing the computer name or “copy” in your synced folders. Change directory to your synced SharePoint path (default is usually under your user profile: C:\Users\<username>\<TenantName>):

:: Search for duplicate files containing the computer's hostname in the synced directory
cd /d "%USERPROFILE%"
dir /s /b "*-%COMPUTERNAME%*" "*copy*"

To automatically delete the duplicate files with your computer name appended (ensure you have backups or have merged changes first):

:: WARNING: This permanently deletes files containing the local computer name in their filename
cd /d "%USERPROFILE%"
for /r %f in (*-%COMPUTERNAME%*) do del "%f"

Step 3: Reset the OneDrive Sync Database

Resetting OneDrive rebuilds the local state database and stops duplicate generation loops:

"%localappdata%\Microsoft\OneDrive\onedrive.exe" /reset

3. Resolve macOS Sync Conflict Duplicates

On macOS, you can use Terminal and bash shell commands to clean up the duplicates created by the OneDrive/SharePoint sync engine.

Step 1: Terminate OneDrive and Office Processes

Open Terminal and kill the syncing services:

killall OneDrive
killall "Microsoft Word" "Microsoft Excel" "Microsoft PowerPoint"

Step 2: Scan for and Remove Duplicates on macOS

On macOS, synced SharePoint libraries are typically stored inside your home directory under ~/Library/CloudStorage or ~/OneDrive.

Run the following command to search for duplicate files (adjusting the search path if you use a custom sync folder):

# Find files containing "copy" or "-MacBook" (or your macOS hostname)
find ~/Library/CloudStorage/ -type f \( -name "*copy*" -o -name "*-$(hostname -s)*" \)

To delete the duplicate files (ensure you have verified their content first):

# WARNING: This deletes all files in the sync folder containing the macOS hostname
find ~/Library/CloudStorage/ -type f -name "*-$(hostname -s)*" -delete

Step 3: Reset the OneDrive Client on macOS

Execute the reset script included in the OneDrive app package:

/Applications/OneDrive.app/Contents/Resources/ResetOneDriveAppStandalone.command

4. Prevent Future Duplicate File Creation

To prevent duplicates from recurring, adjust Office sync collaboration settings:

  1. Open OneDrive Settings (click the OneDrive icon -> gear icon -> Settings).
  2. Navigate to Sync and backupAdvanced settings.
  3. Locate the File collaboration section.
  4. Ensure “Use Office applications to sync Office files that I open” is enabled. When active, Office handles concurrent edits in-memory via co-authoring rather than producing local file conflicts.
  5. In the conflict resolution options, select “Let me choose to merge changes or keep both copies” or “Always keep both copies” (setting it to merge where possible is recommended).

5. Summary Checklist for SharePoint Duplicate Files

CheckpointAction RequiredExpected Result
Process LocksTaskkill OneDrive and Office apps before cleanupUnlocks conflict files for deletion or renaming.
Search Sync FolderRun dir /s /b (Win) or find (Mac) for hostname patternsLocates all conflict duplicates in the folder tree.
Sync Client ResetRun onedrive.exe /reset or Mac standalone reset scriptRebuilds the sync state database and corrects sync loops.
Office IntegrationTurn ON “Use Office applications to sync Office files”Avoids file-level locking conflicts by utilizing co-authoring.
Offline EditsCheck in files or wait for sync to complete before closingGuarantees changes are merged to the cloud version.