#!/usr/bin/perl -w use strict; die "Wrong Number of Arguments" unless $#ARGV == 1; $sourceDir = $ARGV[0]; $days = $ARGV[1]; #foreach $arg (@ARGV) { # print "one arg is $arg\n"; #} opendir source_DIR, $sourceDir or die "ERROR opening: $sourceDir, $!"; @sourceFiles = readdir source_DIR; closedir source_DIR; foreach $file ( @sourceFiles ) { # print( "sourceFiles $file \n" ); # next if -d $sourceDir . "\\" . $file if ($file eq '.') { # do nothing # print "working dir \n"; } else { if ($file eq '..') { # do nothing # print "parent dir \n"; } else { remove_dir( $sourceDir . "\\" . $file ) if -M $sourceDir . "\\" . $file >= $days; } } } # del_file # arg_0 = filename, including full path, to be deleted sub remove_dir { my $file = shift(@_); @args = ( 'rmdir /s /q' , $file ) ; print "system command: @args \n"; system( @args ) == 0 or die "error removing $file!"; } # End move_file