build a playlist with a script :)
Hello All,
I would like to build a playlist of over 500 songs but I dont see anything online that will construct this with a program the playlist format is xspf for jw flash player. format of the song are: Band - Album - 01 - Song1.mp3 Band - Album - 02 - Song2.mp3 Other Band - Other Album - 01 - Other Song.mp3 Other Band - Other Album - 02 - Other Song two.mp3 etc.. File layout for the playlist is <playlist version="1" xmlns="http://xspf.org/ns/0/"> <title>playlist</title> <tracklist> <track> <title>SONG</title> <annotation>BAND</annotation> <location>FILE</location> </track> </tracklist> </playlist> so if I had a script that could basically rip apart the list of songs and build this playlist that would be grand! |
here's a small shell script that might help. this can probably be done more elegantly in perl; too bad i don't like perl that much :); but perhaps someone else on the list might be able to help.
place this script in a file (mkplaylist.sh for example; and remember to 'chmod +x' it). you'll have to edit it to provide the path to your mp3 files or you can make that a command-line parameter that you pass to the script. HTH. -RN. <code> echo "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">" echo "<title>playlist</title>" echo "<tracklist>" find /path/to/mp3files -type f | while read line do FN=`basename "$line"` SONG=`echo $FN | cut -d- -f4 | sed 's/ //g;s/.mp3//'` BAND=`echo $FN | cut -d- -f1 | sed 's/ //g'` echo "<track>" echo "<title>$SONG</title>" echo "<annotation>$BAND</annotation>" echo "<location>$line</location>" echo "</track>" done echo "</tracklist>" echo "</playlist>" </code> |
Well, it will be difficult to do it without knowing the exact delimiter and which field corresponds to which. Anyway, my already weak perl scripting skills were getting rusty. So I decided to try it.
<Warning> This is a 10 minutes script and might have errors</warning> Assumed that your file names are present in list.txt Code:
#!/usr/bin/perl |
tried the perl script and got:
/mkplaylist2.sh: line 3: open: command not found ./mkplaylist2.sh: line 8: print: command not found ./mkplaylist2.sh: line 10: syntax error near unexpected token `)' ./mkplaylist2.sh: line 10: `while(<FILE>) {' |
Sounds like you tried to run a perl script as a shell script, hence the syntax errors.
Given his script above, just check where your perl is installed and adjust the #!/usr/bin/perl line as needed. Save it as mkplaylist.pl and run as ./mkplaylist.pl (assuming rx perms) |
Look in the bash info manual section on HERE documents.
You could have in a loop something like: Code:
cat >>playlist <<EOP |
Quote:
Worked fine after :) |
Thanks GUYS (gals) for the help you made this happen for me! ROCK AND ROLLA :)
|
All times are GMT -5. The time now is 05:28 AM. |