Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found