Created 4 January 2004, last updated 13 January 2004
This utility creates a tree of M3U files (MP3 playlist files) to parallel a tree of MP3 files. Each directory gets an .m3u file named for the directory that includes all of the .mp3 files in the directory and all of its subdirectories.
For example, suppose your MP3 directory has subdirectories for each artist, which have subdirectories for each album, which have .mp3 files for the album’s tracks. Then after running this utility, you will have a .m3u file that includes every track at the root, an .m3u file in each artist directory that includes all that artist’s tracks, and an .m3u file in each album directory that includes all the tracks on the album.
- Python 2.2 or later.
- Jason Orendorff’s path module, which is standard with Python 2.3.
- Sune Kirkeby’s mp3.py, which determines the length of the MP3 file.
- My id3reader, which reads ID3 tags from MP3 files.
Run m3utree.py in the root of your mp3 tree. It will create m3u files at each subdirectory.Download: m3utree.py
7 January 2004: The mp3.py module occasionally fails when trying to read the length of an MP3 file, so I’ve protected against exceptions when calling it.
9 January 2004: Now it doesn’t write the #EXTINF line if it has no information to add there.
13 January 2004: Yet better handling of the #EXTINF line when information is missing, Unicode data is printed without fail.