# Use https://github.com/sreedevk/deduplicator then use # jq 'map(. + {key: (.hash + (.size | tostring))}) | group_by(.key) | map([.[] | .path[22:]])' dup.json # to get the changed.json file. # The script must be ran as admin. $a = cat changed.json | ConvertFrom-Json foreach ($duplicate_files in $a) { foreach ($file in ($duplicate_files | Select-Object -Skip 1)) { Write-Host "Deleting", $file Remove-Item $file $relative_path = [IO.Path]::GetRelativePath([IO.Path]::GetDirectoryName($file), $duplicate_files[0]) Write-Host "Linking", $file, "to", $relative_path cmd /c mklink $file $relative_path } }