Created
July 28, 2024 08:28
-
-
Save HirbodBehnam/b86d4b6318c47bf9b80fbd1ec08906a0 to your computer and use it in GitHub Desktop.
Revisions
-
HirbodBehnam created this gist
Jul 28, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # 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 } }