Skip to content

Instantly share code, notes, and snippets.

@symonerandle
Last active April 7, 2021 19:44
Show Gist options
  • Save symonerandle/59c388cf4c0de45c7857f9b01db7e576 to your computer and use it in GitHub Desktop.
Save symonerandle/59c388cf4c0de45c7857f9b01db7e576 to your computer and use it in GitHub Desktop.
PowerShell: File management script
<--!
Usecase: List duplicate files in directory.
-->
Get-ChildItem -Recurse |
Group-Object Length |
Where-Object { $_.Count -gt 1 } |
Select-Object -ExpandProperty Group |
ForEach-Object { Get-FileHash -LiteralPath $_.FullName } |
Group-Object -Property Hash |
Where-Object { $_.Count -gt 1} |
Select-Object -ExpandProperty Group |
Select-Object Hash, Path
Out-File folder\nestedFolder\textFile.txt -Width 510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment