#!/usr/bin/perl -w use strict; use IO::Dir; my $oggdir = '/media/tmp/'; ParseDirectory($oggdir); sub ParseDirectory { my $dir = shift; my $d = IO::Dir->new($dir) or die "Can not open directory $dir for read!"; while (defined(my $f = $d->read)) { if ($f =~ /.*_+.*\.[Oo][Gg]{2}$/) { # matching files my $new_name = $f; $new_name =~ s/_//; # remove _ # rename $f to $new_name, etc. } else { # non-matching files # do whatever, set to default, etc. } } } #### #!/usr/local/bin/perl -w use strict; use Getopt::Long; # Parse command line arguments and assign corresponding variables GetOptions ( 'i|init=s' => \( my $INIT = undef ), # Specify the root directory 'u|upload' => \( my $UPLOAD = undef ), 'v|verbose' => \( my $VERBOSE = 0 ), ); unless ( defined $INIT ) { print <