in reply to Modified Date, file renaming
### ------------------------------- ### Read local directory opendir LOCALDIR, $location || croak "Unable to open: $location because $!"; @local_files = readdir LOCALDIR; foreach $file (@local_files){ ### Don't try to delete directories if ($file eq '.' || $file eq '..' || -d "$location$file" ) { next; } ### Test the age of each file in the directory and delete ### if too old (N.B. need to prepend directory to find file an +d ### use unlink for OS portable deletion). if ( -M "$location$file" <= $age) { $p_debug && print "$file is ok, only ", -M "$location$file", " days old\n"; } else { $p_debug && print "$file is too old, it's ", -M "$location$file", " days old\n"; unlink("$location$file") || croak "Unable to delete: $location$file because: $!"; } }
You could use something like:
### Move each file into archive directory move( "$location$file", "$target$file") || croak "Unable to move: $location$file because: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Modified Date, file renaming
by ChemBoy (Priest) on May 16, 2001 at 18:12 UTC | |
by Mungbeans (Pilgrim) on May 16, 2001 at 19:59 UTC |