1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- use strict;
- use File::Find;
- use File::Basename;
- use File::stat;
- use Time::Local;
- my $cutofftime;
- sub wanted() {
- return unless -f;
- my $mtime = stat($_)->mtime;
- return if $mtime >= $cutofftime;
- my (undef,undef,undef,undef,$mon,$year,undef,undef,undef) = gmtime $mtime;
- my $bn = basename $_;
- my $dn = dirname $_;
- my @path = split /\//, $dn;
- $path[0] .= sprintf 's-%4d-%02d', 1900+$year, $mon+1;
- $dn = join '/', @path;
- if (! -d $dn) {
- my $p = '.';
- for my $component (@path) {
- $p .= '/'.$component;
- if (! -d $p) {
- mkdir $p or die ("Cannot mkdir $p: $!\n");
- };
- };
- };
- print "$_ -> $dn/$bn\n";
- rename $_, $dn.'/'.$bn or die ("Cannot rename $_ to $dn/$bn: $!\n");
- };
- my (undef,undef,undef,undef,$mon,$year,undef,undef,undef) = gmtime(time - 5*24*3600);
- $cutofftime = timegm(0,0,0,1,$mon,$year);
- find( {
- wanted => \&wanted,
- no_chdir => 1
- },
- 'server-descriptor');
- find( {
- wanted => \&wanted,
- no_chdir => 1
- },
- 'extra-info');
|