tragor Apprentice
Joined: 21 May 2003 Posts: 168 Location: Freiburg i.Br., Germany
|
Posted: Tue Sep 19, 2006 9:00 pm Post subject: HOWTO: Burn songs from a .m3u Playlist in given order... |
|
|
Hi!
Ever wanted to burn a playlist you created in amarok or alike? If you would simply use the function inside amarok to burn all selected titles in the playlist amarok would open k3b and add the files. *But* they wouldn't be in the order they appeared in the playlist, instead they would be sorted by filename!
I had exactly this problem, so I wrote a script that copys all songs in a m3u playlist to the current directory and numbers them. To preserve the original order padding with zeros is used for the counter, so you would get like
Code: |
001_song1.mp3
002_song2 extra long.Mp4
003_another song.aac
...
123_last song.flac
|
Here is the bash script:
Code: |
#!/bin/bash
number=`grep -Eshc '^/' $*`;
i=1;
grep -Esh '^/' $* | while read file; do
count=`printf "%0${#number}d" "${i}"`;
printf "copying file: ${file##/*/} ...";
cp "$file" "./${count}_${file##/*/}";
printf " done!\n";
let i+=1;
done;
|
Just save it in a file named e.g. copyPlaylist, save it in your path and make it executable. Then call it like this
Code: |
sh copyPlaylist [path_to_playlist_file]/playlist.m3u
|
All songs are copied to the current directory.
If you would like to make a mp3 sampler cd or dvd you may want to use mp3gain afterwards to make all mp3s the same volume:
Code: |
sh copyPlaylist [path_to_playlist_file]/playlist.m3u && mp3gain ./*
|
Have fun!
tragor |
|