Deleting Multiple Directories : rmdir « File « Perl






Deleting Multiple Directories

    


#!/usr/local/bin/perl

mkdir ("c:\\",0)||warn "$!";
for ($i = 0; $i < 10; $i++){
  mkdir ("c:\\\\rmdir$i",0)||warn "$!";
}
chdir ("c:\\Testlistings");
use Cwd;
$dir = cwd();
opendir (DH, $dir) || warn $!;
while ($dirName = (readdir(DH))){
   if ($dirName =~ /^rm/){
      print "Removing $dirName\n";
      rmdir ("$dirName") || warn $!;
   }
}

   
    
    
    
  








Related examples in the same category

1.Create dir with mkdir and remove dir with rmdir
2.Removing Directory