This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Newbie Question: MP3-Player export, how to rename files for export

Tags: None
(comma "," separated)
Chazar
Registered Member
Posts
5
Karma
0
Hi! How do I preserve a playlist order when transferring music to an external media-device?

My MP3-Player plays songs only in alphabetical order and does not seem to recognize .m3u files. The settings dialogue for media devices offers many choices for naming the files when transferring them, but I cannot find an option for a serial number based on the current playlist. I thought that prepending a serial number is the easiest way to preserve an Amarok playlist within the mp3-player.  I also thought about using the comment field, but it is too awkward to type in a serial number in the comment field by hand for each song and each playlist. Furthermore my collection is shared with the rest of my family, so altering the comment fields is not a good option too. What can I do?

(BTW, thanks for Amarok! It is truly  a great Application! Oh, and my the player I refer to above is a  Samsung YP-U2; its merit being its capability to play OGG-audio.)
eborges
Registered Member
Posts
3
Karma
0
This is a very simple script. Simple means badly coded :(. Works to convert (from ogg to mp3) and copy m3u lists to cheap mp3 players, maintaining its sequence. The csh script use an awk (very, very old...) function, which must exist in the same directory. You must install lame and sox to do the conversion. If you do not want to convert, just use the skeleton to rename and add the number of the position of the music into the playlist. Here they are:

The awk function (copy it to the file m3u2mp3.awk):

#------------------------------------------------------------------------------------
BEGIN { { linha = 1 } { print "#!/bin/csh" } caminho = cam }

{ FS="[.:,]" }
{
if ( $1 !~ "#EXTM3U" ) {
    if ( $1 ~ "#EXTINF" ) {
{ nome = $NF }
{ linha ++ }
    } else {
if ( $NF ~ "ogg" ) {
    { printf "sox \"%s\" tmp.wav\n", $0 }
    { printf "lame tmp.wav " }
    { printf " \"%s/%s/", caminho, FILENAME }
    { if ( linha < 10 ) printf  "00" }
    { if ( linha >= 10 ) printf "0" }
    { printf "%s - %s.mp3\"\n" , linha, nome }
} else {
    { printf "cp -rf " }
    { printf " \"%s\" ", $0  }
    { printf " \"%s/%s/", caminho, FILENAME }
    { if ( linha < 10 ) printf  "00" }
    { if ( linha >= 10 ) printf "0" }
    { printf "%s - %s.mp3\"\n" , linha, nome }
}
    }
}
}
#------------------------------------------------------------------------


And the csh script ( i did call it m3u2mp3.csh):

#!/bin/tcsh
if ( $2 == "" ) then
mkdir tmp
mkdir ./tmp/$1.m3u
awk -f m3u2mp3.awk -v cam=tmp $1.m3u > comands.csh
else if ( $2 != "" ) then
#if ( $2 == /media/usbdisk ) then
mkdir $2/$1.m3u
awk -f m3u2mp3.awk -v cam=$2 $1.m3u > comands.csh
endif

chmod 755 ./comands.csh
./comands.csh

Call the script ./m3u2mp3.csh

It does not works correctly with lots of meta caracters on the filenames. Truly, its is not a fully functional script. I did promise to myself I'will write it as a amarok plugin...
best regards
edilson


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]