Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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 # <> # use strict; use File::Find; use MP3::Info; my $Debug = 0; my $usage = " <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

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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?

    What's my password?
    Create A New User
    [LanX]: hippo: I'm telling him constantly to upgrade to postgress...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2018-03-19 09:38 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (238 votes). Check out past polls.