Waclaw Chrabaszcz
... there is no spoon ...

PowerShell – duplicated files in Windows Media Player library

Saturday, July 12, 2014 5:19 PM

Holiday! .. But why it's raining. Let's cleanup some duplicated MP3s. Maybe the rain will stop in the meantime.

For sure this code is not optimized, and I am not recommending anyone to use it. If you uncomment move actions you can reduce number of duplicated media files in your Windows Media Player library.

You can consider it as an example how to access and browse WMP using PowerShell.

 

$wmp = New-object –COM WMPlayer.OCX
$playlist = $wmp.mediaCollection.getAll()
$i=1
do {
if ($playlist.item($i).sourceURL -like "*.mp3")
{
if ($playlist.item($i).name -eq $playlist.item($i-1).name)
{
write-host "n-1 : " $playlist.item($i-1).sourceURL
write-host $playlist.item($i).name " : " $playlist.item($i).sourceURL
if ($playlist.item($i).sourceURL.tostring().length -gt $playlist.item($i-1).sourceURL.tostring().length )
{
Write-Host -ForegroundColor yellow "moving " $playlist.item($i).sourceURL
#Move-Item $playlist.item($i).sourceURL "c:\output"
}
else
{
Write-Host -ForegroundColor red "moving " $playlist.item($i-1).sourceURL
#Move-Item $playlist.item($i-1).sourceURL "c:\output"
}
}
}
$i++
}
while ($i -le ($playlist.count -1))

Ahh .. A quick description, you've got media files in many folders. The script checks WMP library and in case of conflict wins the file with shorter URLpath. To move files uncomment #Move-Item. And let WMP rebuild library before next script run. It may take up to 3 days.




Feedback

# re: PowerShell – duplicated files in Windows Media Player library


How many of you know about LG G7 News ? 8/30/2017 10:39 AM | LG G7 release date

Post a comment