Create .m3u playlist file from dir contents

This script creates a 00-playlist.m3u file with the mp3, ogg or flac files in the current folder.
The m3u format delivered has the basic syntax, no # tags inside. But it works everywhere, foobar2000, vlc, winamp, so...

This post can also be used to make a similar utility based in create a file with the filenames listed.

The utility needs a Windows Powershell script.

Here we go:

  1. Create a Powershell script with the code:

    Get-ChildItem *.* -include *.flac,*.ogg,*.mp3 -name | Out-File -Encoding UTF8 00-playlist.m3u
    

    (You can change the output filename '00-playlist.m3u' here)
    In this example we save this code in the file C:\Users\jp\App\powershell\createm3u.ps1

    IMPORTANT:
    If this is the first time you use this Windows Powerscript, you need to grant yourself exec permissions.
    Go to the Powershell console (search 'powershell' in windows start button) and type:

    Set-ExecutionPolicy RemoteSigned
    

    And confirm.
    You only have to do this thing only one time in you computer. More info here.

  2. Now go to DOpus and create the button. This is the code:

    See how to add buttons from this forum to your toolbars for how to paste the XML.

     <?xml version="1.0"?>
     <button backcol="none" display="both" textcol="none">
     	<label>Create m3u</label>
     	<tip>Create m3u playlist file</tip>
     	<icon1>#play2</icon1>
     	<function type="batch">
     		<instruction>powershell.exe C:\Users\jp\App\powershell\createm3u.ps1</instruction>
     	</function>
     </button>
    

    If you prefer doing it manually, without pasting the XML:

    • Right-click over empty space on toolbar->[Customize].
    • Right-click over toolbar where you want the button->[New->Button]
    • Right-click over newly created button->[Edit...]
    • Define icon, label ('Create m3u'), Tip ('Create m3u playlist file')
      There is a pretty suited icon with a musical note in the 'Tools' icon section.
    • Select Function->MS-DOS Batch Function.
    • Put this code:
      powershell.exe C:\Users\jp\App\powershell\createm3u.ps1
      Note that the path is my example path. Make sure yours is correct.
    • Press OK

This is it. Now if you press this button when in a folder with mp3, ogg or flac files, it will create the .m3u file with them.

hey!
thanks for your nice script!

i have one problem with it. my use case is like that.
when i have looong audio books (ken follet for example) it has many many many mp3s in one folder.

i want to work it like this. every ten files the script shall create a .m3u, not only one for all...

i got a script that does that with the marked files and asks me for the cd number:

@NOFILENAMEQUOTING
@RUNMODE HIDE

@set CD={dlgstring|CD}

Echo #EXTM3U>"{sourcepath$|nopath|noterm}_CD{$CD}.m3u"
Echo {file$}>>"{sourcepath$|nopath|noterm}_CD{$CD}.m3u"

it works fine but i have to do it by myself in the end. ken follet has over 450 mp3s ... you do the math.

how can i tell the script to cycle through aaall the files and make every ten files a new m3u?

Solano, take a look at my new script for DO11.

I have done it before, but had a harddisccrash an when I tried to do it again it dont work. I was deny to change the registerkey and this is what happen. Any that now what to do. I love the script so I realy want it :slight_smile:

PS C:\Users\zikke> Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy : Åtkomst till registernyckeln HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft
\PowerShell\1\ShellIds\Microsoft.PowerShell nekas.
At line:1 char:20

  • Set-ExecutionPolicy <<<< RemoteSigned
    • CategoryInfo : NotSpecified: (:slight_smile: [Set-ExecutionPolicy], UnauthorizedAcce
      ssException
    • FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.C
      ommands.SetExecutionPolicyCommand

Uhmmm... maybe you must be logged with an Administrator account (or make 'zikke' Administrator) or maybe run the powersell console via right click and selecting "Run as an administrator..."

So simple... just open as administrator and its works perfect..... just stupid , thanks :thumbsup: