I am so mean, that I even give the script away now.
I think that you really should keep voting me down! (there are always going to be things that I won't understand in the world, even in nice places like PM:-( )
Note: the script might have to be run several times, because it does not delete directories when they still have files in them. - Just keep running it until 0 file and 0 directory are deleted.
#!/usr/local/bin/perl -w
use File::Find;
$workingdir = 'C:/TEMP/';
$countdirs = 0;
$countfiles = 0;
$testmode = 0;
@extensions = ('txt','obj'); #files to remove
@directories = ('win32-VC60','CVS','Cvs'); #directories to remove (rec
+ursively with all the files/subs in them)
@anymatches = ('ChangeLog'); #other special matches to remove as well
find(\&processmatch, $workingdir);
print "\n$countfiles file(s) and $countdirs director(y)(ies) were dele
+ted.\n\n";
sub processmatch{
# Note: we are chdir in the current directory!
$saved = $_;
$name = $File::Find::name;
$deleteflag = 0;
foreach $ext(@extensions)
{
if($name =~ /.*\.$ext/)
{
$deleteflag = 1;
}
}
foreach $dir(@directories)
{
if($name =~ /.*\/$dir.*/)
{
$deleteflag = 1;
}
}
foreach $any(@anymatches)
{
if($name =~ /.*$any.*/)
{
$deleteflag = 1;
}
}
if($deleteflag == 1)
{
if (-d $name)
{
if(!$testmode)
{
rmdir $name;
}
print "$name\n";
$countdirs++;
}
else
{
if(!$testmode)
{
unlink $saved;
}
print "$saved\n";
$countfiles++;
}
}
$_ = $saved;
}
BTW: Thanks for the persons who helped me!