use strict;
use Getopt::Long qw(Configure);
use ID3FS::DB;
+use File::Find;
use vars qw($me);
$me=($0=~/(?:.*\/)?(.*)/)[0];
my $verbose=0;
my $help=0;
my $init=0;
+my @extensions=qw(mp3 ogg flac);
Configure(qw(bundling no_ignore_case));
my $optret=GetOptions(
"verbose|v" => \$verbose,
"quiet|q" => sub { $verbose=0; },
"help|h" => \$help,
+ "extensions|e=s" => sub { @extensions=split(/\s+|\s*,\s*/, $_[1]); },
"init|i" => \$init,
);
my $path=shift;
my $db=ID3FS::DB->new($path, $init, $me);
+File::Find::find( {wanted => \&wanted, follow => 1, no_chdir => 1}, $path);
+
+sub wanted
+{
+ my $ext='';
+ if(/.*\.(.*)/) { $ext=lc($1); }
+ if(-d)
+ {
+ print("$_\n") if $verbose;
+ }
+ elsif(-f && scalar(grep({ $ext eq lc($_);} @extensions)))
+ {
+ $db->add($_);
+ }
+}
+
sub usage
{
die("Usage: $me [-v] [-q] [-h] [--] file...\n".