My New Hugo Site

Powershell - kasowanie duplikatów plików w katalogu

Get-ChildItem -Path . -File -Recurse | ForEach-Object {
    [PSCustomObject]@{
        Path = $_.FullName
        Hash = Get-FileHash -Path $_.FullName -Algorithm SHA256 | Select-Object -ExpandProperty Hash
        LastWriteTime = $_.LastWriteTime
    }
} | Group-Object -Property Hash | ForEach-Object {
    $_.Group | Sort-Object LastWriteTime -Descending | Select-Object -Skip 1
} | Remove-Item -Force
Tags: