SkullOne has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use POSIX; use File::Copy; use File::Basename; use File::stat; my $src; my $dst; print "\nEnter Source Directory: "; chomp($src = <STDIN>); $dst = $src; $dst =~ s/inbox/queue/g; print "\nDESTINATION DIRECTORY SET TO: $dst\n"; chdir $src || die "Can't chdir to !\n" ; my $count; my $limit; print "\nEnter File Limit: "; chomp($limit = <STDIN>) $count = 1; for my $file (<*.imap>) { $count = $count + 1; my ($name,$path,$suffix) = fileparse($file,"\.imap") ; my $info = stat($file); my $datestamp = strftime("%Y%m%d", localtime($info->mtime)); mkdir "$dst\\$datestamp" or "Error making Directory $!\n"; print "\n Moving \"$file\" >> $dst\\$datestamp"; move $file,"$dst\\$datestamp\\$name$suffix" or warn "Cannot copy $ +file $!\n"; if($count > $limit) { print "\n \nFile Limit Reached. Stopping\n"; exit;} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Fast file and directory operations
by mr_mischief (Monsignor) on Mar 11, 2008 at 20:04 UTC | |
|
Re: Fast file and directory operations
by kyle (Abbot) on Mar 11, 2008 at 20:17 UTC | |
|
Re: Fast file and directory operations
by halfcountplus (Hermit) on Mar 11, 2008 at 20:30 UTC | |
by zentara (Cardinal) on Mar 12, 2008 at 13:20 UTC | |
|
Re: Fast file and directory operations
by Roy Johnson (Monsignor) on Mar 11, 2008 at 19:55 UTC |