# encoding: ascii
# api: powershell
# title: Remove-DeadITunesTracks
# description: This script will go through your ITunes library and check the paths for each of the Tracks. If it doesn’t find a file at the specified location it will remove that track from your ITunes Library.
# version: 0.1
# author: Mark Schill
# license: CC0
# x-poshcode-id: 595
# x-archived: 2015-03-14T01:47:33
# x-published: 2009-09-20T23:51:00
#
#
Clear
$ITunes = New-Object -ComObject iTunes.Application
1..$ITunes.LibraryPlaylist.Tracks.Count | % {
$CurrentTrack = $ITunes.LibraryPlaylist.Tracks.Item($_)
# File Track ??
if ( $CurrentTrack.Kind -eq 1 )
{
if ( ! ([System.IO.File]::Exists($CurrentTrack.Location)) )
{
Write-Host "$($CurrentTrack.Artist) - $($CurrentTrack.Name) has been deleted."
$CurrentTrack.Delete()
}
}
Write-Progress -activity "Removing Dead Tracks" -status "$($CurrentTrack.Artist) - $($CurrentTrack.Name)" -percentComplete ( $_/$ITunes.LibraryPlaylist.Tracks.Count*100)
}