Need help creating a script to read a wpl file and copy the files to 1 folder.

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of random commandline random commandline 8 months, 1 week ago.

  • Author
    Posts
  • #37096
    Profile photo of Trent Perez
    Trent Perez
    Participant

    I am very new to PowerShell and came across a PowerShell script but cannot make it work or even understand how it's suppose to work. The creator said that they passed the playlist file and the folder to the script as parameters and it extracted the file/path information from the playlist file for every song and copied the music files to the folder. Well after doing alot of research I find I keep getting information that doesn;t quite fit this situation and I need help understanding how PowerShell handles the data in a .wpl file since it doesn't seem to be a true xml file. I have startied looking into the XmlDocument object but I am getting lost in all the examples that don;t quite explain where the commands do. I could really use a good pointer on where I should focus my research. Like what commands I should be looking at and where I can find a good reference on syntax of the different cmdlets. I am including an example of the playlist file I am trying to extract from in case that might help someone understand what I am trying to accomplish. https://gist.github.com/zipster1967/8d30b85cbc42e60d66d24d7e10b3138a"

  • #37100
    Profile photo of random commandline
    random commandline
    Participant

    You should be able to extract song name and location from the playlist with something like this. Will you paste a portion of the wpl file to your post? I think most playlists are in xml format.

    $wpl = [xml](Get-Content .\playlist.wpl)
    $wpl.xmlelements.xmlelement | foreach {'Do Something'} 
    
  • #37165
    Profile photo of Trent Perez
    Trent Perez
    Participant

    I discovered that media player is able to create m3u playlist files which do not have the weird replacements that exist in wpl files (['] being replaced by [&apos] so I now just need to extract all the lines that are not blank, and do not start with the pound sign # If anyone has an idea on how to do that please let me know.

  • #37174
    Profile photo of random commandline
    random commandline
    Participant
    # Exclude comment and empty lines
    $col = {@()}.Invoke()
    switch -Regex -File .\path\to\playlist.m3u{
    {$_ -ne "" -AND $_ -notmatch "^#"}{$col.Add($_)}
    }
    
    $col | Out-File .\path\to\playlist.txt
    

You must be logged in to reply to this topic.