Return to Snippet

Revision: 44268
at April 8, 2011 22:22 by FazzyX


Initial Code
#!/usr/bin/perl
use strict;

use File::Find;
use File::Path;
use Digest::MD5 qw{md5_hex};

if(!($ARGV[0] && $ARGV[1])){
	print "Keine oder nicht genuegend Parameter mitgegeben, Programm wird beendet.\n";
	print "Aufruf : <Program> <SearchPath> <DeleteItem>...\n";
	exit;
}

(my $startToSearchDir, my $deleteItem) = @ARGV;

find(\&wanted, $startToSearchDir);
 
sub wanted {
	if($_ eq $deleteItem){
		if(-d $File::Find::name) {
		    print "Deleting : " . $deleteItem . "\n";
			rmtree($deleteItem);
		} else {
			print "Deleting : " . $deleteItem . "\n";
			unlink($deleteItem);
		}
	} 
}

Initial URL

                                

Initial Description
Recursive delete of given file or folder, e.g. .svn folder
Call  : [Program] [SearchPath] [DeleteItem]

Initial Title
SearchAndDestroy

Initial Tags
perl

Initial Language
Perl