OT: creating m3u playlists

Steve Holmes steve at holmesgrown.com
Wed Jun 15 14:35:55 EDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

I have a little perl hack I use around here that recurses from the
current directory on down that writes a .m3u playlist to standard out.
Just run it like this:
ls2playlist . >playlist.m3u

- ----- Begin script -----
#!/usr/bin/perl -w
# Converts a listing from "ls -RQ <dir>" to a playlist type file that
# would be compatible with freeamp and be linux compatible.

$directory = $ARGV[0];
open(LS, "ls -RQ \"$directory\"|") || die "Could not open input stream";
while($rec = <LS>) {
	if($rec =~ /^$|\/$/) {
		next;
	}
	if($rec =~ /^\"(.*)\"\:$/) { #look for directory name
		$path = $1;
		next;
	}
	if($rec =~ /^\"(.*)\"/) {
		$filename = $1;
	}
	if($filename =~ /\.mp3$|\.ogg$/i) {
		print "$path/$filename\n";
	}
}
- ----- End script -----

- -- 
HolmesGrown Solutions
The best solutions for the best price!
http://ld.net/?holmesgrown
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.7 (GNU/Linux)

iD8DBQFCsHULWSjv55S0LfERAyn5AJ9YO7DE4e7s+wtgK6wtXwBHRcJmwwCg8+4i
I5X01vO01UF+4bAPtcXm3CE=
=ZOAx
-----END PGP SIGNATURE-----




More information about the Speakup mailing list