Help with an m3u playlist button

Hello Leo,

thanks for this button I mounted yet.

2 Questions:

  1. Many mp3 contain a "&" in the name and the buttons order do a break on making the m3u. :frowning:

  2. My music is organized by music\artist\album\artist-title.mp3. I would like to name my Playlist "artist-album.m3u". Do you know a way to take the next higher level of the album-directory for naming?

Thanks for helping please!

  1. You're right.

    I hate MS-DOS.

    If you put quotes around the string then the & is fine, but then you get quotes in the output which breaks the .m3u file.

    If you remove the quotes then each & needs to be turned into ^& but I don't know an easy way to do that that will work here.

    AFAIK, there's no way to feed echo a quoted string (to avoid having to escape the & characters) and tell it not to echo the quotes. Stupid thing.

    TBH, I'd re-write it in VBScript rather than fight with MS-DOS any further, but I don't have time to do that myself.

  2. That part is easier. You can use {filepath$|..|nopath|noterm} and {filepath$|..\..|nopath|noterm} to get the names of the parent and parent-parent folders.

[quote="leo"][ol][li]I hate MS-DOS.[/li]
[li] That part is easier. You can use {filepath$|..|nopath|noterm} and {filepath$|....|nopath|noterm} to get the names of the parent and parent-parent folders.[/li][/ol][/quote]

Hi Leo,
thanks for pointing that out.
One way is to rename/replace & to ^& in the filenames and back at the end of batch. The problem of Echo touches only {file$}, not {filepath$} for naming the m3u.
My son did the batch for me. I added to get the artist...
Works for me (...and for any other who need).

<?xml version="1.0"?>
<button display="both" separate="yes">
	<label>Create M3U</label>
	<icon1>48</icon1>
	<function type="batch">
		<instruction>@NOFILENAMEQUOTING</instruction>
		<instruction>@RUNMODE HIDE</instruction>
		<instruction>Select PATTERN *.(mp3|ogg|flac|aac|wma) DESELECTNOMATCH</instruction>
		<instruction>Rename PATTERN &amp; TO ^&amp; FINDREP</instruction>
		<instruction>Echo #EXTM3U&gt;&quot;{filepath$|..\..|nopath|noterm}-{sourcepath$|nopath|noterm}.m3u&quot;</instruction>
		<instruction>Echo {file$}&gt;&gt;&quot;{filepath$|..\..|nopath|noterm}-{sourcepath$|nopath|noterm}.m3u&quot;</instruction>
		<instruction>Rename PATTERN ^&amp; TO &amp; FINDREP</instruction>
	</function>
</button>

Another Thankyou...

Greetings, Eike
Create M3U.dcf (727 Bytes)

No go here.
Choked on artist like
Hootie & the Blowfish,
Crosby, Stills, Nash & Young

titles like Knockin' on Heaven's Door

Basically, anything with multiple "&" " ' " in artist name, song,
multiple artist listings...

I'm aware you didn't account for " ' "...

...

[quote="NEBB"][quote="eike"]
Works for me (...and for any other who need).
[/quote]

No go here.

Basically, anything with multiple "&" " ' " in artist name, song,
multiple artist listings...

I'm aware you didn't account for " ' "...
...[/quote]

I'm sorry for your trouble, but it works (here...)

[broken image links to external site]

DOpus 9.5.2.0.3660.x64
Win7x64
I'm not very near to Buttons or scripting.
Your Button is on MS-DOS-Batch-Mode...?

[quote="NEBB"] No go here.
...[/quote]

A thought: Is this problem healed on Unicode-version of DOpus, which is installed on my system...?

regards, Eike

There haven't been non-Unicode versions of Opus for a long time so it's probably not that, unless someone's running a really, really old version.

Thinking along those lines, though, it could be a difference with DOS codepages, but I can't think why they'd affect the & character.

One thing to do is make the button print out what it's doing, like I did earlier in the thread to see if anything is obviously wrong.

Another thing it could be is file path limits. If the track names + paths are already close to the max-path limit of 256 characters, temporarily renaming them to insert extra ^ characters may push them over the limit.

But, like I said before, I've learnt to give up on MS-DOS batch approaches as soon as they run into problems. It always takes longer to make MS-DOS batches behave properly (if it's possible at all) than to re-write the thing using another method. :slight_smile:

Here's a VBScript I found that almost does what we want and which would make good starting point:

mikesalsbury.com/2006/01/vbscrip ... rectories/

(I'd have a go myself but am a little sleep deprived at the mo. :slight_smile:)

[quote="eike"][quote="NEBB"] No go here.
...[/quote]
regards, Eike[/quote]

The culprit was KAV.

:unamused: :smiley:

Here is a slight modification to read the grandparent... ie. if you have Artist/Album/mp3s
You get Air_MoonSafari.m3u (for example.)
Cheers
A.

@NOFILENAMEQUOTING
@RUNMODE HIDE
@set grandparent {sourcepath$|..|nopath|noterm}


Select PATTERN *.(mp3|ogg|flac|aac|wma|m4a) DESELECTNOMATCH

//Its simply making a text fiel...
//Get parent folder for Artist...  Bowie / young americans/


Echo #EXTM3U>"{$grandparent}_{sourcepath$|nopath|noterm}.m3u"

//And now add all the files that are selected in the folder.
Echo {file$}>>"{$grandparent}_{sourcepath$|nopath|noterm}.m3u"

Your code did not come over correctly with the forum upgrade. The > symbol got converted to _
Please fix
Also how can I sort the {file$} to be by name, my default view is by modified date, but in the m3u i want it by name.

Forum thread should be fixed now.

If your default sort isn't the same as you want the files to be listed, you may be able to make the command change the sort order, although I am not sure that would work (it may be too late once the command starts running).

Re-writing it as a proper script (VBScript or JScript) is probably the best option, which would allow arbitrary sorting and also better unicode support than using the MS-DOS batch method from so many years ago.

I took your advice and created an updated script here

Please share any thoughts.

1 Like