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

Copy a Windows Media Player playlist to another location.

John Savill

February 25, 2012

2 Min Read
ITPro Today logo in a gray background | ITPro Today

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.ps1write-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 sensitiveforeach ($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:tempmp3
Searching file Boxing.wpl for media files and sending to d:tempmp3

Copying file D:MultimediaMusicThe Ultimate Remix .mp3
Copying file D:MultimediaMusicOriginal SoundtrackRoad Trip5 - Anything, Anything (I'll Give You).mp3
Copying file D:MultimediaMusicCrazy TownButterfly2 - Butterfly (Epic Remix).mp3
Copying file D:MultimediaMusicStone SourCome What(ever) May9 - Socio.mp3
Copying file D:MultimediaMusicFall Out Boy - I Dont Care [Single Version].mp3
Copying file D:MultimediaMusicLady GaGaThe Fame3 - Paparazzi.mp3
Copying file D:MultimediaMusic50 CentIn da Club1 - In da Club.mp3
Copying file D:MultimediaMusicSnapThe Madman's Return9 - Rhythm Is A Dancer.mp3
Copying file D:MultimediaMusicVarious ArtistsNow, Vol. 223 - Ridin'.mp3
Copying file D:MultimediaMusicEmfVarious18 - Emf - 6 - Unbelieveable.mp3
Copying file D:MultimediaMusic5_-_Remember_The_Name_(Album_Version)_[Explicit].mp3
Copying file D:MultimediaMusicSnap!World Power1 - The Power.mp3
Copying file D:MultimediaMusicVarious ArtistsSmallville, Vol. 1 - The Talon Mix1 - Save Me.mp3
Copying file D:MultimediaMusicLady GaGaThe Fame Monster (Deluxe)12 - Poker Face.mp3
Copying file D:MultimediaMusicMuseThe Resistance1 - Uprising.mp3
Copying file D:MultimediaMusicVarious ArtistsThe Rocky Story2 - Burning Heart.mp3
Copying file D:MultimediaMusicEminemRecovery [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

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like