[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] File migration quicky
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;