Absolute path formatting

I am using a script that I found in this forum to export to XSPF playlist format.

It works fine for relative paths, but for absolute paths when using MP3Tag's %_path% command it does not result in the correct format of path required by XSPF, so the playlist file does not work.

How can I change this kind of path:
T:\Temp\Sample Files\Audio Formats\out2.flac

into this kind of path:
file:///T:/Temp/Sample%20Files/Audio%20Formats/out2.flac

It probably needs regex (but I don't know how to use that).

I think a simple replace is enough:
file:///$replace('T:\Temp\Sample Files\Audio Formats\out2.flac',\,/, ,'%20')
Put the text constant "file:///" in front and then the replace statement.

Thank you for your reply.

When you break it down like that, that the changes don't seem quite as complicated as I first thought (although I still would not have been able to figure out how to construct the correct 'replace' command).

The solution that you provided had me a bit confused at first because you included an actual path in your answer. But then I realised that it's just the output of %_path%, so I substituted the path with the placeholder and it works!

<location>$replace(file:///$replace(%_path%,\,/, ,'%20'),&,&amp;)</location>

Thanks.

I think that the part "file:///" is not really the most elegant way.
<location>file:///$replace(%_path%,\,/, ,'%20',&,&amp;)</location>
should be it

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.