m3udo


m3udo is a batch processing utility that allows you to apply a command
to each line of a text file in the M3U format.  It is similar to the
xargs command, except that it supports of number of niceties useful
for batch processing.  Things you might do with it include moving a
collection of files to a common directory, converting all files from
one format to another, or calculating FFTs of an entire album.

Usage: 
   m3udo [switches] [command] [file(s)]

Switches:
   -r: Recursive.  If any item in an m3u file is an m3u file, open and
       process it recursively.  

Command argument:
   The default behavior is to run the command once for each line in
   the m3u file.  By default each line is appended to the command, so
   the result will be a string of commands like:

      sha1sum myfirst.wav
      sha1sum mysecond.wav

   If the command contains "{}", "{}" will be replaced in the command
   by the file.  This allows you to insert a file reference into a
   command somewhere other than at the end.

File argument(s):
   Any arguments after the command are assumed to be files in the m3u
   format, meaning files containing lists of files.

   A file named "-" is interpreted to mean standard input.

   A line in an m3u file beginning with "#" is considered a comment.

   A line in an m3u file ending with ".m3u" is assumed to be an m3u
   file.  If m3udo was invoked with the "-r" flag, the line is
   processed recursively.

   Before passing a line to a command, whitespace at either end and
   DOS-fuxored carriage returns are trimmed.

Examples:
   m3udo ls my.m3u
	    will run the ls command on each item in my.m3u.
   m3udo wget my.m3u 
	    will fetch items that are HTTP urls.
   m3udo "mv {} newdir/" my.m3u
	    will move items to a new directory.
   m3udo "wget {}; basename {} >> cache.m3u" my.m3u 
	    will fetch items that are HTTP urls and create a new
	    playlist with local copies.
   m3udo ls *.m3u
	    will run the ls command on each item in all m3u files.
   cat my.m3u | m3udo ls -
	    will run the ls command on each item in my.m3u.
   m3udo -r ls my.m3u
	    will run the ls command on each item in my.m3u, and on
	    each item in any m3u files contained in my.m3u, ad
	    recursivitum.

Notes:
   In comparison to xargs, you should find m3udo easier to use.  In
   comparison to for loops in the bourne shell, you should find m3udo
   involves less typing.  In comparison to hand-rolled scripts, you
   should find m3udo less buggy and more secure.

   m3udo is not aware that M3U files usually contain lists of audio
   files.  In its view M3U is simply a standard format for batch
   processing -- entries could just as well be images or any other
   kind of data.

Security:
   m3udo passes filenames contained within an m3u file as arguments to
   a shell command.  It is possible for attackers to use shell
   metacharacters in filenames to attack your system.  You can defend
   against this by inspecting the names of downloaded files before
   operating on them with m3udo.

Screenshot:
   

Download:
   http://gonze.com/m3udo/latest

Installation:
   * Download the latest version and rename it to "m3udo".  
   * Make it executable by doing "chmod 755 m3udo".   
   * If perl is not installed in /usr/bin/perl on your system, you will
     need to change the first line of the the script from
         #!/usr/bin/perl
     to
         #!/usr/local/bin/perl
   or wherever your perl is installed.
   
Contact:
   lucas@gonze.com