[Omaha.pm] File migration quicky

Jay Hannah jhannah at omnihotels.com
Mon Apr 2 14:09:43 PDT 2007


Wrote this quick and dirty thing today.

*nix gods probably have a command-line way? I suppose I could Perl golf
it just for fun...

j



#!/usr/bin/perl

# staging_migrate.pl
#
# Recursively move all .XLS files in
#   /oracle/reports/archive-staging
# to
#   /oracle/reports/archive
# keeping the relative path the same.

my $dir1 = "/oracle/reports/archive-staging";
my $dir2 = "/oracle/reports/archive";

open (IN, "find $dir1 -name '*.XLS' |");
while (<IN>) {
   my $old = $_;
   my $new = $old;
   $new =~ s/$dir1/$dir2/;
   rename $old, $new or die "Can't rename '$old' to 'new'";
}
close IN;



More information about the Omaha-pm mailing list