in reply to Check Directories for Files
well Perl has got this two cool functions (among others:)) :
that is it :)opendir(); readdir(); so what you could do is: use strict; use warnings; use File::Copy; opendir (DIR,"./path") || die "$!"; # this opens the directory foreach my $i(readdir DIR){ next if (/\./g || grep{$_=~/$i/g}22..50); move("./path/$i", "/tmp/$i"); # if (-e "./path/$i"); } closedir DIR;
UPDATE:
my bad, tollic is right, so basically what you do is check if the var in question is a regular file or not:
sorry :)next unless(-f "./path/$i" || !grep{$_=~/$i/g}22..50);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Check Directories for Files
by toolic (Bishop) on Nov 24, 2009 at 20:03 UTC |