Mp3tag Export script for organising music in UMS/MSC players

After I bought my new Samsung Yp-U3 (MSC mode) player, I discovered that the latest firmware (1.12WA) has limitations with regards to reading files from file directory folders: it is able to play files in folders in repeat mode or in shuffle mode, but it is unable to play only files within the folder sequentially once. For example, if I have two folders each containing ten mp3s. If I were to select the fifth mp3 of the first folder in the default play mode, the mp3 player will play all the remaining mp3s from both folders sequentially until there are no more files left and the player then automatically shuts down. There is no way that the player will only play songs from one folder, unless it is the last folder in the list. This is a big problem for me because I often listen to music when I’m about to sleep and it’s obviously not a good thing if the music player keeps playing nonstop. Sleep mode doesn’t do it for me because if I’m listening to audiobooks for instance this becomes an annoyance.

I found out that this problem can be worked around through the use of playlists. But for some really annoying reason, the mp3 player only reads .spl playlists, which (I believe) is generated by iTunes and the Samsung mp3 software, both of which I hate to use. Winamp only supports .m3u and .pls playlists; don’t even get started about Windows Media Player which I also detest, in which any case generates only .wpl playlists that the Yp-U3 doesn’t even recognise(!)

Anyway, after racking my brains for a couple of hours, I discovered the wonders of certain Mp3tag functionalities that I never really explored before: the Export and Actions functions. I’d used the Export function to generate md5 checksums of mp3s (md5s of the actual mp3 file sans id3 tags) before but never realised how powerful it could be via the use of Regex.

The following Export function script I wrote allows playlist to be automatically generated for music files listed in any location in the mp3 player’s file structure, and generates .spl playlists into the Playlist folder based on the file location and album id3tag field.

$filename($trim($regexp(%_path%,^(.{2}).*,\1)\Playlist\$if($neql(len(%artist%,0)),%artist%,Various) - $if($neql(len(%album%,0)),%album%,Album)).spl,utf-16)SPL PLAYLIST
VERSION 1.00

$loop(%_path%)$regexp(%_path%,^.{2},)
$loopend()
END PLAYLIST

Note: The One file per directory checkbox under Export must be selected

I used the above in conjunction with an Actions Format value code which sorts files first according to artist, then album title:

Field: _FILENAME
Format string: $regexp(%_path%,^(.{2}).*,\1)\Music\%artist%\%album%\$num(%track%,2) - %title%

The Export function code should be used after the Format value code, i.e. you can place both of them sequentially within the same Action Group so that they can be executed in one step.

The result of the above is that now all I need to do is to dump all mp3s (that have been correctly id3-tagged with at least Album, Artist and Track Number) into the Music folder (or any other folder) within the mp3 player, drag and drop the folder into Mp3tag, then execute the script via Alt-5. This will rename all the files according to the form [artist]\[album]\[track no] - [title].mp3/wma/wav/ogg and generate individual .spl files based on the artist and album title. Based on my usage, this saves me a lot of time and is even easier than using an mp3 player like Winamp to manage my files.

Subjects: Music 音楽, Technology 技術

Tags: Mp3tag, MSC, music, UMS