Duplicate File Finder Script

I’ve been trying to cleanup my Plex Library, and since I’m retrieving videos from a couple sources like TiVo and DVDs, I’m undoubtedly encountering doubles.  Now, there are handful of issues you run into like ignoring case and file extension.

Used Get-Duplicate Method from here 

[code language=”powershell”]
Function Get-Duplicate {
param($array, [switch]$count)
begin {
$hash = @{}
}
process {
$array | %{ $hash[$_] = $hash[$_] + 1 }
if($count) {
$hash.GetEnumerator() | ?{$_.value -gt 1} | %{
New-Object PSObject -Property @{
Value = $_.key
Count = $_.value
}
}
}
else {
$hash.GetEnumerator() | ?{$_.value -gt 1} | %{$_.key}
}
}
}

Function Show-Duplicates{
param($drive)
begin {
$duplicates = Get-Duplicate (Get-ChildItem $drive
| Foreach-Object {$_.BaseName}).ToLower() | Sort-Object

if($duplicates.Length -eq 0)
{
Write-Host "No Duplicates"
}
else
{
$duplicates | Sort-Object
}
}
}
[/code]