in reply to Unix - Keep the last modified file in the directory and move/copy the rest of the files.
use File::Copy; my $src = '/path/to/source/directory'; my $tgt = '/path/to/target/directory'; opendir SRC, $src or die $!; my @files = sort { -M $a <=> -M $b } readdir SRC; shift @files; move("$src/$_", "$tgt/$_") for @files;
Update: fixed as noted below.
--"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Unix - Keep the last modified file in the directory and move/copy the rest of the files.
by sauoq (Abbot) on Jun 06, 2003 at 09:56 UTC | |
|
Re^2: Unix - Keep the last modified file in the directory and move/copy the rest of the files. (common readdir trap)
by Aristotle (Chancellor) on Jun 07, 2003 at 00:29 UTC |