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)

J

In reply to moving files to mp3 player by opqdonut

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.