Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#!c:\perl\bin\perl.exe -w # # WinAMP M3U Sorted Playlist Generator version .0.1 ("Bob") December 2 +001 # <xunker@pyxidis.org> # use strict; use File::Find; use MP3::Info; my $Debug = 0; my $usage = "listmaker.pl <source dir> <output file> [<verbose>]\n"; my ($source_path, $output_filename, $verbose) = @ARGV; die $usage unless (($source_path) && ($output_filename)); die "that path doesn't exist, hombre" unless (-e $source_path); unlink $output_filename if (-e $output_filename); my @files; my %shortname; sub addFile { $shortname{$File::Find::name} = $_; return unless -f; return unless /\.mp3$/; push @files, $File::Find::name; print '.' if $verbose; } print "\n" if $verbose; find (\&addFile, $source_path); @files = sort {uc($a) cmp uc($b)} @files; open FILE, ">$output_filename" or die "could not open $output_filename for writing: $!"; print FILE "#EXTM3U\n"; my $counter = 1; my $max = scalar (@files); foreach my $file (@files) { my $tag = get_mp3tag($file); my $info = get_mp3info($file); my $pair; if (($tag->{ARTIST}) && ($tag->{TITLE})) { $pair = $tag->{ARTIST} . ' - ' . $tag->{TITLE}; } else { $pair = $shortname{$file}; } print FILE "#EXTINF:" . int ($info->{SECS}) . "," . $pair . "\n"; $file =~ s/\//\\/g; # this is for WinAMP/MS-DOS; # by default, File::Find returns # filenames with the forward # (proper) slash, but I use the # program in Windows, so... # If you use a real OS, remove. print FILE "$file\n"; print "$counter of $max: $pair\n" if $verbose; $counter++; } close FILE;

In reply to M3U Playlist Generator by xunker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (8)
    As of 2015-07-28 10:28 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (254 votes), past polls