Created
May 6, 2014 04:01
-
-
Save jackgill/12afe3167f2dff4e4032 to your computer and use it in GitHub Desktop.
DeDup-iTunes.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Finds duplicate iTunes tracks, and if the -Delete parameter is specified, deletes them. | |
.PARAMETER Delete | |
Delete duplicate tracks | |
#> | |
[CmdletBinding()] | |
param( | |
[switch] $Delete | |
) | |
$itunes = New-Object -com itunes.application | |
$tracks=$itunes.LibraryPlaylist.Tracks | |
$seen = @{} | |
foreach ($track in $tracks) { | |
if (-not $track.Location) { | |
continue | |
} | |
if ($seen.ContainsKey($track.Location)) { | |
$track.Location | |
if ($Delete) { | |
$track.Delete() | |
} | |
} | |
else { | |
$seen.Set_Item($track.Location, $True) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment