How to Create an M3U Playlist from a Folder of Music

How to Create an M3U Playlist from a Folder of Music

The short answer: write a text file listing the paths to your tracks, one per line, with an #EXTM3U header at the top. Save it as .m3u and any M3U-compatible player will read it.

The longer answer is below, including how to do it by hand, how to do it with a script, and where a browser tool saves time.


What an M3U file actually is

An M3U playlist is a plain text file. A minimal one looks like this:

#EXTM3U
music/artist/album/01-track.flac
music/artist/album/02-track.flac
music/artist/album/03-track.flac

Most players also support the extended format, which adds a display name and duration for each track:

#EXTM3U
#EXTINF:214,Artist - Track Title
music/artist/album/01-track.flac
#EXTINF:253,Artist - Second Track
music/artist/album/02-track.flac

The #EXTINF line holds the duration in seconds (before the comma) and the display name (after it). The path on the next line is what the player actually opens. That is the whole format.


Option 1: Build it by hand in a text editor

For a small folder with a handful of tracks, writing the playlist manually is fast enough.

  1. Open a plain text editor. On Mac, use TextEdit in plain text mode (Format > Make Plain Text). On Windows, Notepad works. On Linux, gedit, nano, or anything else.
  2. Type #EXTM3U on the first line.
  3. For each track, add the path to the file on its own line. Most players prefer forward slashes, even on Windows.
  4. Save the file with a .m3u extension. In TextEdit you may need to rename it afterwards to remove the .txt extension the editor adds by default.

This works, but for a folder with fifty tracks it means fifty lines of manual typing, and if you ever move the folder, every path breaks and you start over.


Option 2: Generate it from the command line

If you are comfortable in a terminal, you can generate an M3U from a folder in one command.

Mac and Linux:

{ echo "#EXTM3U"; find /path/to/music -type f \( -name "*.flac" -o -name "*.mp3" -o -name "*.ogg" \) | sort; } > playlist.m3u

This finds every matching audio file in the folder, sorts them alphabetically, and writes the paths to playlist.m3u under an #EXTM3U header.

Windows (PowerShell):

$header = "#EXTM3U"
$files = Get-ChildItem -Path "C:\Music" -Recurse -Include "*.flac","*.mp3","*.ogg" | Sort-Object FullName | Select-Object -ExpandProperty FullName
($header, ($files -join "`n")) -join "`n" | Set-Content -Encoding UTF8 playlist.m3u

The command-line approach is fast and reproducible. The downside is that you get no easy way to reorder tracks, remove specific entries, or curate what goes in before you export, and it writes absolute paths, which break if the playlist or the music moves.


Option 3: Use a browser tool

If you want to scan a folder, pick which tracks go in, arrange the order, and export a clean playlist file without touching a terminal, a browser-based tool is the practical route.

Using Emthree:

  1. Go to emthree.app. No account needed, nothing to install.
  2. Load your music folder. In Chrome or Edge you pick the folder with the native folder picker, and Emthree can remember it so you reopen with one click. In Safari or Firefox you drag the folder onto the page instead, and re-drag it each session, since those browsers don't keep the folder permission between visits. Either way, Emthree reads the files locally on your device. Nothing is uploaded.
  3. Your tracks appear as a browsable list. Filter by artist, album, or filename.
  4. Add tracks to your playlist, drag them into the order you want, and remove any you don't need.
  5. Export the finished .m3u file.

Two things Emthree handles for you here. It writes #EXTINF lines from the tags in your files, so your player shows real track titles rather than raw filenames. And it writes relative paths rather than absolute ones, which is what keeps the playlist working after you move it or hand it to a self-hosted server. It will also stop an export if the tracks and the playlist don't share a common root folder, since that would produce paths that can't resolve.


Relative vs absolute paths

This is the decision that determines whether your playlist survives being moved.

Absolute paths point to the full location on your machine, like /home/user/music/album/track.flac. They work as long as the file stays at that exact path, but break the moment you move your music folder or open the playlist on another machine.

Relative paths point from wherever the playlist file sits, like music/album/track.flac. They survive as long as the playlist and music keep the same position relative to each other, which makes them portable. A common setup is to keep the playlist at the root of your music folder and use relative paths from there.

If you build by hand or from the command line, this is on you to get right. If you use Emthree, it writes relative paths automatically, so you don't have to think about it.

Jellyfin, Navidrome, and Plex all handle both kinds of path. If you are building for a server, check what it expects.


Checking your playlist works

Once you have the file, the quickest test is to open it in VLC or your player of choice. If tracks play, the paths are correct. If you see a list of errors or nothing loads, the paths are wrong.

Common things to check:

  • Forward vs backslashes. Most players, including Jellyfin and Navidrome, expect forward slashes (/) even on Windows.
  • Case sensitivity. On Linux and most NAS systems, /Music/Artist and /music/artist are different paths. Match the actual folder names exactly.
  • File extensions in paths. The path needs the extension (.flac, .mp3) to match the real filename.

Keeping it up to date

A playlist built from a folder snapshot goes stale whenever you add or move files. Two ways to handle that:

  • Rebuild on change. Re-scan and re-export when the folder changes. Fast with a browser tool, scriptable from the command line.
  • Smart playlists. Emthree's Pro plan includes rule-based smart playlists that auto-update as your library changes, by artist, album-artist, genre, year, or year range. Worth it if you add music regularly and want playlists to stay current without manual rebuilds. Pro is £15 per year.

For most people, rebuilding on change is fine, and once you have the workflow it takes a couple of minutes.