#!/usr/bin/perl -w # Ian Beckwith # use lib '/home/ianb/projects/id3fs/id3fs/lib'; 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 $basedir=undef; my $dbpath=undef; my @extensions=qw(mp3); # ogg flac); # FIXME Configure(qw(bundling no_ignore_case)); my $optret=GetOptions( "verbose|v" => \$verbose, "quiet|q" => sub { $verbose=0; }, "help|h" => \$help, "basedir|d=s" => \$basedir, "database|db=s" => \$dbpath, "extensions|e=s" => sub { @extensions=split(/\s+|\s*,\s*/, $_[1]); }, ); usage() if(!@ARGV || !$optret || $help); if(@ARGV > 1 && !defined($basedir)) { die("$me: --basedir must be specified if multiple paths are supplied\n"); } my $db=ID3FS::DB->new($me, $dbpath, $basedir, $ARGV[0]); $db->last_update(time()); while(my $path=shift) { 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))) { s/^\.\///; $db->add($_); } } sub usage { die("Usage: $me [-v] [-q] [-h] [--] file...\n". " -v\tVerbose\n". " -q\tQuiet (default)\n". " -h\tThis help\n". " --\tEnd of options\n"); } __END__ =head1 NAME program - description =head1 SYNOPSIS B<> [I<-v>] [I<-q>] [I<-h>] [I...] =head1 DESCRIPTION =head1 OPTIONS =over 4 =item B<-v> Enable verbose operation. =item B<-q> Quiet (no output). This is the default. =item B<-h> Show a short help message. =item B<--> End of options. =back =head1 FILES =head1 ENVIRONMENT =head1 DIAGNOSTICS =head1 BUGS None known. Please report any found to ianb@erislabs.net =head1 SEE ALSO =head1 AUTHOR Ian Beckwith =head1 AVAILABILITY The latest version can be found at: B =head1 COPYRIGHT Copyright 2010 Ian Beckwith This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . =cut