Many mp3 contain a "&" in the name and the buttons order do a break on making the m3u.
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?
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.
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 & TO ^& FINDREP</instruction>
<instruction>Echo #EXTM3U>"{filepath$|..\..|nopath|noterm}-{sourcepath$|nopath|noterm}.m3u"</instruction>
<instruction>Echo {file$}>>"{filepath$|..\..|nopath|noterm}-{sourcepath$|nopath|noterm}.m3u"</instruction>
<instruction>Rename PATTERN ^& TO & FINDREP</instruction>
</function>
</button>
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.
Here's a VBScript I found that almost does what we want and which would make good starting point:
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.
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.