Hi All! I wrote this today as a quickie fix for an easy problem. I have this directory full of directories for mp3 files. I wanted to be able to browse using a remote media player and play an entire album. The script below goes into each directory and generates an m3u file for that directory. (Will not generate an m3u if no mp3 files are present.) It's quick and dirty, but very useful if you have this same problem.
#!/usr/bin/perl -w use strict; use File::Find::Rule; # Change this next line to reflect your mp3 directory my @dirs_only = File::Find::Rule->directory()->in('/steeler/mp3'); foreach( @dirs_only ) { my $dir = $_; chdir( "$dir" ); chomp( my @files = `ls` ); my $files = `ls`; if (( $files =~ /\.mp3$/ ) or ( $files =~ /\.MP3$/ )) { my $current_dir = `pwd`; my $basename = `basename \"$current_dir\"`; $basename =~ s/\s//g; $basename =~ s/'//g; $basename =~ s/\.//g; my $m3u_file = "$basename".'.m3u'; print "Creating m3u file: $m3u_file\n"; open M3U, ">$m3u_file"; foreach( @files ){ print M3U "$_\n"; } close M3U; } }
This script assumes you are running on a unixy-type system, I'm sure some of those shelled-out commands won't work on windows.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Generate m3u files automatically
by Corion (Patriarch) on May 07, 2010 at 07:27 UTC | |
|
Re: Generate m3u files automatically
by graff (Chancellor) on May 07, 2010 at 08:20 UTC | |
by ikegami (Patriarch) on May 07, 2010 at 20:44 UTC | |
|
Re: Generate m3u files automatically
by rementis (Beadle) on May 07, 2010 at 19:38 UTC |