2009/02/15

Perlで1日以上古いファイルのgzip圧縮(特定ディレクトリを以下すべてを再帰的に)

#!/usr/bin/perl

use File::Find;

@directories_to_search = "圧縮したいファイルの保管されたディレクトリのフルパス";
find(\&wanted, @directories_to_search);

sub wanted{
my $file = $File::Find::name;
if ($file =~ /\.gz/) {
} else {
if (-f $file){
system ("/bin/gzip $file")
# print $file,"\n"
if (-M "$file" > 1);
}
}
}

0 件のコメント: