Separating music playlists with Python

December 29, 2011 - Words by Marko Kuder

December 29, 2011
Words by Marko Kuder

Do you spend a lot of time organizing and cleaning up your music? These python scripts may help.

Personal music collections usually grow over time. If you spend a large part of your free time searching for new songs and new artists (that possibly haven’t yet been discovered and still make free music), your song collection is probably measured in thousands of titles, if not tens of thousands.

If you want to keep up the quality of your collection, you need to clean up from time to time by erasing songs you realized you don’t really like that much. You also may want to separate the music you really like from music you don’t know that well yet.

For these two reasons I’ve written a couple of python scripts that make m3u (Winamp) playlists based on the hidden file attribute (Windows file systems). One makes a playlist out of all hidden files and another out of all non-hidden files. Since then I’ve been using a system where I mark all the songs I’m sure to keep as hidden. This way, when I want to listen to music I really like, I generate and load up the hidden-file playlist. When I want to listen to music which I don’t know that well yet or I’m not sure whether to keep or erase it, I load the non-hidden playlist. You could also use it in reverse or for marking special songs for certain playlist (e.g. for parties).

Usage is simple. Simply put the scripts into the top directory from which you wish to generate the playlist (it will search all subdirectories) and run from there. I’ve prefixed their names with ZZZ so they should be at the bottom when alphabetical order is used. They will generate equally named .m3u8 playlist files. The scripts include comments so you can modify them to your choosing (e.g. for Linux systems). In addition to the hidden/nonHidden generating scripts I’ve also included a script for generating a complete list of all songs. You will of course need Python. The scripts may also put some non-music files into the playlists (they only exclude some common extensions, see comments in scripts for details).

If you use Winamp for listening and want to clean up songs easier, I can recommend the File Deleter plugin. It puts icons in the system tray, which you can use to quickly send songs to the recycle bin.


Social media

Keep up with what we do on our social media.