Created
June 9, 2012 17:03
-
-
Save jamesmanning/2901813 to your computer and use it in GitHub Desktop.
PowerShell script to remove dead entries from the iTunes library
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
# get reference to the running iTunes | |
$itunes = New-Object -ComObject iTunes.application | |
# get all tracks in the entire library | |
$allTracks = $itunes.LibraryPlaylist.Tracks | |
# find the entries that are no longer on disk | |
# NOTE: the API returns the location as null for those, so we check for | |
# that instead of doing our own filtering based on test-path or similar | |
$deadEntries = $allTracks | ?{ $_.Location -eq $null } | |
# now that we know which entries are invalid, delete them from the library | |
$deadEntries | %{ $_.Delete() } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment