This in my first perl project after some 2 years of not using perl, it's made to move predefined sets of files (or "aliases") to my muvo mp3 player.
All sorts of suggestions are welcome, as the code is not very polished and my syntax is probably crude :)
Things I plan on adding are: id3 tag matching, filename caching (so we don't have to use 'find' on that 5 gig mp3 dir every time ;), putting the files into directories on the player (as in /mnt/muvo/$alias>/$file.mp3) and adding a section in the config file for setting the $mp3dir et al.
# 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 no +rmal 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 (<CONF>) { 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 actu +al work foreach (@install) { $verbose && print "\n", $_, ":\n\t", $aliases{$_}[0], ": ", $alias +es{$_}[1], "\n"; if ($aliases{$_}[0] eq "name") { $regexp = $aliases{$_}[1]; find(\&namefound, $mp3dir); # print $regexp . "\n"; } else { print STDERR "Matching type \"", $aliases{$_}[0], "\" not supporte +d.\n"; # only path matching at this stage } } close(CONF)
In reply to moving files to mp3 player by opqdonut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |