#!/bin/perl -w ############################# # # ARCHiVE v0.6 by avizion # (freebsd edition) # # (Tested successfully on Slackware 9) # # Script parameter needed: # Set $completetag to the dir complete your zipscript makes. # NOTE: Your zipscript _have_ to write a file/dir with genre. # Next version will make use of mp3info. # ############################# #use strict; my $test = 1; my $ignoreComplete = 0; my $completetag = "complete"; my $maxDepth = 1; my $onlyDoCopy = 0; my %genres = ( "psychadelic" => "/glftpd/site/archive/mp3/psychedelic/monthly/current", "psychedelic" => "/glftpd/site/archive/mp3/psychedelic/monthly/current", "ambient" => "/glftpd/site/archive/mp3/ambient/monthly/current" ); my $CMD_NICE = "/usr/bin/nice"; my $CMD_FIND = "/usr/bin/find"; my $CMD_CP = "/bin/cp"; my $CMD_MV = "/bin/mv"; ################################## ### DON'T TOUCH ANYTHING BELOW ### ################################## my $start = $ARGV[0]; my $source = ''; my (@find,@dirs); my ($found,$genre,$path); if($#ARGV < 0) { print "Missing argument: \\n"; exit 1; } sub checkdir { my $target = shift; opendir TARGET, $target or die "Directory $target not found!\n"; return closedir TARGET; } checkdir( $start ); while ( ($genre,$path) = each %genres ) { checkdir($path); print "Fetching all in genre $genre\n"; if($ignoreComplete == 0) { $grepComplete = "| grep -i $completetag"; } else { $grepComplete = "| grep -iv $completetag"; } @find = `$CMD_NICE -5 $CMD_FIND $start/* -type d -maxdepth $maxDepth $grepComplete | grep -i $genre`; foreach $found (@find) { chomp($found); @dirs = split(/\//,$found); if( substr($found,0) eq '/' ) { $source = '/'; } else { $source = ''; } for(my $i=0; $i<$#dirs+$ignoreComplete; $i++) { $source .= $dirs[$i] . '/'; } chop $source; $source =~ s/\(/\\\(/g; $source =~ s/\)/\\\)/g; print "Found $source... "; if($test == 0) { if($onlyDoCopy == 1) { print "Copying to $path"; `$CMD_CP -R $source $path`; } else { print "Moving to $path"; `$CMD_MV $source $path`; } } print "\n"; } #print @find; }