Delete duplicate files based on file size

Solution 1:

There's a program that can help you with that.

DupeGuru is a free and open source software to find duplicate files. You can use that to search duplicates, and select what to conserve depending on file size, date, etc.

Solution 2:

In PowerShell you can do this:

Get-ChildItem -Path 'X:\TheDirectory' -Filter '*.cvs' -File -Recurse |
    # group the files on the part of the name before the first underscore
    Group-Object @{expression = {($_.Name -split '_')[0]}} | ForEach-Object {
    # sort the items in the group on Length; skip the last one (the largest file)
    $_.Group | Sort-Object Length | Select-Object -SkipLast 1 | 
        # and remove the rest
        ForEach-Object { $_ | Remove-Item -WhatIf }
}

Remove the -WhatIf safety switch if you are satisfied the info in the console shows the correct files would be deleted.