Q: How do I copy all the files on a Windows Media Player playlist to another location?

A: Windows Media Player uses an XML format to store the playlists and includes all the files and locations of the music files. I created a small Windows PowerShell script that parses the playlist file, finds the files, and copies them to the passed location. The script is shown below:

# copyWPL.ps1
write-host "Searching file "$args[0]" for media files and sending to "$args[1]"`n"

[System.Xml.XmlDocument] $xd = new-object System.Xml.XmlDocument
$file = resolve-path($args[0])
$xd.load($file)

$dest = $args[1]
if (!$dest.EndsWith("\")) #if no ending slash we need to add it
{ $dest = $dest + "\"}

$nodelist = $xd.selectnodes("/smil/body/seq/media") # XPath is case sensitive
foreach ($mediaNode in $nodelist) 
{
    $src = $mediaNode.getAttribute("src")
    write-host "Copying file $src"
    Copy-Item $src $dest
}

write-host "`nCompeted Copy`n"

 

To use it, I pass the playlist file and the location to copy the extracted music files to. An example is shown below (and no comments on my music choices).

 PS D:\temp> .\parseWPL.ps1 Boxing.wpl d:\temp\mp3
Searching file Boxing.wpl for media files and sending to d:\temp\mp3

Copying file D:\Multimedia\Music\The Ultimate Remix .mp3
Copying file D:\Multimedia\Music\Original Soundtrack\Road Trip\5 - Anything, Anything (I'll Give You).mp3
Copying file D:\Multimedia\Music\Crazy Town\Butterfly\2 - Butterfly (Epic Remix).mp3
Copying file D:\Multimedia\Music\Stone Sour\Come What(ever) May\9 - Socio.mp3
Copying file D:\Multimedia\Music\Fall Out Boy - I Dont Care [Single Version].mp3
Copying file D:\Multimedia\Music\Lady GaGa\The Fame\03 - Paparazzi.mp3
Copying file D:\Multimedia\Music\50 Cent\In da Club\1 - In da Club.mp3
Copying file D:\Multimedia\Music\Snap\The Madman's Return\9 - Rhythm Is A Dancer.mp3
Copying file D:\Multimedia\Music\Various Artists\Now, Vol. 22\3 - Ridin'.mp3
Copying file D:\Multimedia\Music\Emf\Various\18 - Emf - 6 - Unbelieveable.mp3
Copying file D:\Multimedia\Music\05_-_Remember_The_Name_(Album_Version)_[Explicit].mp3
Copying file D:\Multimedia\Music\Snap!\World Power\01 - The Power.mp3
Copying file D:\Multimedia\Music\Various Artists\Smallville, Vol. 1 - The Talon Mix\1 - Save Me.mp3
Copying file D:\Multimedia\Music\Lady GaGa\The Fame Monster (Deluxe)\12 - Poker Face.mp3
Copying file D:\Multimedia\Music\Muse\The Resistance\01 - Uprising.mp3
Copying file D:\Multimedia\Music\Various Artists\The Rocky Story\2 - Burning Heart.mp3
Copying file D:\Multimedia\Music\Eminem\Recovery [Explicit]\15 - Love The Way You Lie [Explicit].mp3

Completed Copy

 The script also works with Zune playlists that are XML based.

Got technology issues? We've got technology answers. Check out John Savill's FAQs for Windows

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish