# muvo.pl version 0.1 by Joel Kaasinen # a tool to move prederfined sets of files to some directory # useful for managing a mp3 player (designed for my creative muvo) #!/usr/bin/perl #use strict; use File::Find; use File::Copy; my $conf = "muvoconf"; my @install = @ARGV; # no need for fancy options at this stage my $mp3dir = "/home/opqdonut/mp3"; my $muvodir = "/mnt/muvo"; # place where the mp3 player is mounted my %aliases; my $verbose = 1; # find and copy sub for name matching: name matches regexp and is a normal file (not dir) sub namefound { /$regexp/ && -f && ( my $status = system("cp", $File::Find::name, $muvodir) ); if ($status) { print $File::Find::name; } } open(CONF, $conf) or die "Aaargh, couldn't open conf file!\n"; while () { my $type; my $rule; my $name; #print; ($name, $type, $rule) = split(" "); # parse $aliases{$name}[0] = $type; # config $aliases{$name}[1] = $rule; # file } $verbose && print "aliases to install:\n"; # do the actual work foreach (@install) { $verbose && print "\n", $_, ":\n\t", $aliases{$_}[0], ": ", $aliases{$_}[1], "\n"; if ($aliases{$_}[0] eq "name") { $regexp = $aliases{$_}[1]; find(\&namefound, $mp3dir); # print $regexp . "\n"; } else { print STDERR "Matching type \"", $aliases{$_}[0], "\" not supported.\n"; # only path matching at this stage } } close(CONF)