Free Republic
Browse · Search
General/Chat
Topics · Post Article

To: tacticalogic
I don't know. Tell me how you'd find a list of all duplicate files on your computer with powershell. I'm talking of actual duplicate files here. The names may be different, but the files are exactly the same by actual content.

I have a 5-line bit of shellcode that does a pretty good job of it.

42 posted on 05/29/2015 12:19:44 PM PDT by zeugma (Are there more nearby spiders than the sun is big?)
[ Post Reply | Private Reply | To 41 | View Replies ]


To: zeugma

In the current version (V4)

$md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$ht = @{}
get-childitem c:\ -Recurse -File |
Select -ExpandProperty FullName |
foreach {
$hash = [System.BitConverter]::ToString($md5.ComputeHash([System.IO.File]::ReadAllBytes($_.FullName)))
$ht[$hash] += @($_.FullName)
}

$ht.GetEnumerator() |
Where {$_.Value.count -gt 1}

V5, which will be released with Windows 10 has a Get-FileHash command that would simplify that down to about half as many lines of code.

So, by what measure is that not nearly as powerful as sed, awk, and grep ( assuming that’s what your 5-line bit of shell code is using to find those duplicate files).


43 posted on 05/29/2015 12:53:30 PM PDT by tacticalogic ("Oh, bother!" said Pooh, as he chambered his last round.)
[ Post Reply | Private Reply | To 42 | View Replies ]

Free Republic
Browse · Search
General/Chat
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson