icloud

iCloud Duplicate Files

Resolution Checklist

  • 1 Understand why iCloud creates duplicate files
  • 2 macOS: Find and delete duplicate files via Terminal
  • 3 Windows: Clean up duplicate files using PowerShell
  • 4 Resolve metadata database locks and time sync conflicts
  • 5 Summary Checklist for iCloud Duplicate Files

iCloud Duplicate Files

When iCloud encounters conflicts during file sync, it creates duplicate copies of files instead of overwriting edits. You will see files suffixed with ” (1)”, ” (2)”, ” (2nd copy)”, or ” - conflicted copy”. This clutters folders and wastes storage space.

This guide explains how to automatically find and purge duplicate files, and how to stop the sync engine from generating duplicates on macOS and Windows.


1. Understand why iCloud creates duplicate files

iCloud generates duplicates under three main scenarios:

  • Simultaneous Offline Edits: When a file is updated on two devices while offline, iCloud preserves both versions to prevent data loss.
  • Local and Cloud Database Mismatch: If the local SQLite index drifts from the cloud database, the sync daemon assumes the local file is a new item and re-uploads it with a suffix.
  • System Clock Offsets: If client devices have different clock times, the sync daemon cannot determine which modification came first and writes both to the directory.

2. macOS: Find and delete duplicate files via Terminal

On macOS, you can use the Unix shell tools to find and delete duplicates.

Step 1: Scan and List Duplicate Files in iCloud Drive

Before deleting files, check for duplicates containing conflict suffixes:

  1. Open Terminal.
  2. Run this command to list all duplicate files with (1), (2), or conflict tags:
    find ~/Library/Mobile\ Documents/com~apple~Clouddocs -type f \( -name "* (1).*" -o -name "* (2).*" -o -name "*conflict*" \)

Step 2: Delete Duplicates Safely

If the list looks correct and you want to delete them:

  1. Run the deletion command:
    find ~/Library/Mobile\ Documents/com~apple~Clouddocs -type f \( -name "* (1).*" -o -name "* (2).*" -o -name "*conflict*" \) -delete

Step 3: Purge Cached Metadata

To prevent the client from recreating duplicates:

  1. Clear the local cache:
    killall bird
    rm -rf ~/Library/Application\ Support/CloudDocs

3. Windows: Clean up duplicate files using PowerShell

On Windows, you can use PowerShell to find and delete duplicates in your iCloud Drive folder.

Step 1: Scan for Duplicate Files via PowerShell

  1. Open PowerShell.
  2. Run this command to search for files with duplicate suffixes in your iCloud Drive:
    Get-ChildItem -Path "$env:USERPROFILE\iCloudDrive" -Recurse | Where-Object { $_.Name -match '\s\(\d+\)\.' -or $_.Name -like "*conflict*" } | Select-Object FullName

Step 2: Delete Duplicate Files

  1. Run this command to delete the duplicates:
    Get-ChildItem -Path "$env:USERPROFILE\iCloudDrive" -Recurse | Where-Object { $_.Name -match '\s\(\d+\)\.' -or $_.Name -like "*conflict*" } | Remove-Item -Force

Step 3: Purge and Restart the iCloud Service

  1. Force close the Windows iCloud client to clear memory states:
    taskkill /f /im iCloudDrive.exe /im iCloudServices.exe
  2. Relaunch the client from the Start Menu.

4. Resolve metadata database locks and time sync conflicts

  • Synchronize System Clocks: Ensure both macOS and Windows devices are syncing to NTP time servers.
    • macOS: sudo sntp -sS time.apple.com
    • Windows: w32tm /resync
  • Inspect Third-Party Backup Software: If you run local backups (e.g., Backblaze, Acronis) concurrently with iCloud Drive, they can touch file attributes. This flags the file as modified, causing iCloud to duplicate the file. Set backup software to ignore your iCloud sync folders.

5. Summary Checklist for iCloud Duplicate Files

ComponentmacOS Action CommandWindows Action CommandExpected Outcome
List Duplicatesfind . -name "* (1).*"Get-ChildItem ... -match '\s\(\d+\)\.'Identifies files with conflict suffixes.
Delete Duplicatesfind . -name "* (1).*" -deleteGet-ChildItem ... | Remove-ItemPurges duplicate files.
Reset Databaserm -rf .../CloudDocsN/AForces iCloud to re-align directory trees.
Force Restartkillall birdtaskkill /f /im iCloudDrive.exeRestarts clean file sync threads.
Time Syncsudo sntp -sS time.apple.comw32tm /resyncAligns file modification time markers.
Software ConflictAdd exclude rules in backup toolsAdd exclude rules in backup toolsPrevents background tools from locking files.