OT: creating m3u playlists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----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-----




[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux