#!/bin/gawk -f ######################################################################### # ABOUT: # # Name: m3u2pla-awk # # Version: 1.0 # # Description: A very simple little m3u to pla/plp converter for # unix/linux/etc # # BS: Copyright 2006 Micah Tischler # Any and all warranties are disclaimed, even implied merchantibility. # All use of this is at your own risk. # (But I doubt it'll blow things up, all the same.) # ######################################################################### # USAGE: # # Command: m3u2pla-awk # ^-- you need to include the name & # suffix # # Assumptions: This script presently depends on music being laid out in the # following manner: # artist/album/track.mp3 # # The artist and album heirarchies don't need to be right, they # just need to be there. # # # Enjoy -Micah # ######################################################################### # CODE: BEGIN { if (ARGC!=3){ print "usage: m3u2pla-awk " exit } infile=ARGV[1] outfile=ARGV[2] printf("Generating "outfile" from "infile".\n") printf("Parsing m3u.") buffer=sprintf("PLP PLAYLIST\r\nVERSION 1.20\r\n\r\n") while (getline < infile) { if (match($0,"/[^/]+/[^/]+/[^/]+[.]mp3")) { song=substr($0,RSTART,RLENGTH) gsub("/","\\",song) buffer=sprintf("%sHARP, MUSIC%s\r\n",buffer,song); printf(".") } } close (infile) printf("\nWriting pla.") for (c=1;c<=length(buffer);c++){ printf("%c\00",substr(buffer,c,1)) > outfile if (!(c%45)) printf(".") } close(outfile) printf("\nDone.\n") }