Search code examples
vb.netm3u

Parse M3U file locations to fully qualified paths


I would like to parse the file location information in an M3U playlist into fully qualified paths. The possible formats in M3U files seem to be:

c:\mydir\songs\tune.mp3

\songs\tune.mp3

..\songs\tune.mp3

For the first example, just leave it alone. For the second add the directory that the playlist resides in so it would become c:\playlists\songs\tune.mp3 and the same for the third case so it would also become: c:\playlists\songs\tune.mp3.

I'm using vb under VS2008 and I can't find a way to recognise each of the potential location formats in the M3U file. System.IO.Path offers no solution that I can find. I've searched extensively for terms like "convert relative path to absolute" but no luck.

Any advice appreciated.

Thanks.


Solution

  • Write a batch script that just reads the m3u file line by line, and then just parse each line looking for ":" , and for "..", and edit the string as needed. You can then just write the "converted" strings to another file...